Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: create pg_trm extension for the GIN index creation #36722

Merged
merged 3 commits into from
Oct 7, 2024

Conversation

AnaghHegde
Copy link
Member

@AnaghHegde AnaghHegde commented Oct 7, 2024

Description

Due to the size limit on the BTree index we are creating GIN index for a permission group. To support this we need to create a pg_trm extension.

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11212861701
Commit: d62be8f
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Mon, 07 Oct 2024 10:46:39 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced database initialization by adding the creation of the pg_trgm extension for PostgreSQL, improving text search capabilities.
  • Bug Fixes

    • Ensured the extension is created only if it does not already exist, preventing unnecessary errors during setup.

@AnaghHegde AnaghHegde self-assigned this Oct 7, 2024
@AnaghHegde AnaghHegde requested review from abhvsn and removed request for sharat87 and pratapaprasanna October 7, 2024 09:12
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Oct 7, 2024
Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The pg-utils.sh script has been updated to create the pg_trgm extension for PostgreSQL within the init_pg_db function. This modification checks for the existence of the database and schema, and if the extension is not present, it creates it for both local and remote PostgreSQL setups. The script now includes a logging statement to indicate when the extension is created, while maintaining the original structure and logic of the database initialization process.

Changes

File Path Change Summary
deploy/docker/fs/opt/appsmith/pg-utils.sh Added creation of pg_trgm extension in init_pg_db function, including logging for actions.

Possibly related PRs

  • chore: Add grants for appsmith user for embedded postgres #36664: This PR modifies the pg-utils.sh script to enhance PostgreSQL management by adding a new function for granting permissions and updating the init_pg_db function, which is directly related to the changes made in the main PR that also modifies the init_pg_db function to include the creation of the pg_trgm extension.

Suggested labels

Move to Postgres, DB Infrastructure Pod

Suggested reviewers

  • sharat87
  • pratapaprasanna
  • abhvsn

🎉 In the land of databases, a new extension grows,
The pg_trgm shines bright, as everyone knows.
With a check and a log, the script takes its flight,
PostgreSQL's future is looking quite bright!
So let’s cheer for the changes, with joy we shall sing,
For every new feature, a reason to bring! 🌟


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ef634c0 and d62be8f.

📒 Files selected for processing (1)
  • deploy/docker/fs/opt/appsmith/pg-utils.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • deploy/docker/fs/opt/appsmith/pg-utils.sh

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@AnaghHegde AnaghHegde added the ok-to-test Required label for CI label Oct 7, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 95010fd and 2569c33.

📒 Files selected for processing (1)
  • deploy/docker/fs/opt/appsmith/pg-utils.sh (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
deploy/docker/fs/opt/appsmith/pg-utils.sh (2)

Line range hint 1-159: Class, let's summarize our review of the pg-utils.sh script.

Overall, the addition of the pg_trgm extension is a positive change that aligns with the PR objective of creating a GIN index. You've done a good job integrating this new functionality into the existing script structure.

However, there are a few areas where we can improve:

  1. Adding error handling for both local and remote setups.
  2. Using IF NOT EXISTS to prevent potential errors.
  3. Ensuring the correct user is used for remote setups.

These changes will make the script more robust and less prone to errors. Remember, in database management, it's crucial to handle potential issues gracefully.

Keep up the good work, and don't hesitate to ask if you have any questions about the suggested improvements!


131-133: 🛠️ Refactor suggestion

Class, let's examine the creation of the pg_trgm extension for local PostgreSQL setups.

Good job on adding the pg_trgm extension! This will indeed help with text search operations. However, let's make a small improvement to avoid potential errors:

Consider modifying the command to use CREATE EXTENSION IF NOT EXISTS pg_trgm;. This way, we won't encounter an error if the extension already exists. Here's how you can update it:

 echo "Creating pg_trgm extension..."
-psql -h "$PG_DB_HOST" -p "$PG_DB_PORT" -U postgres -d "$PG_DB_NAME" -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
+psql -h "$PG_DB_HOST" -p "$PG_DB_PORT" -U postgres -d "$PG_DB_NAME" -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"

Also, it would be beneficial to add error handling. Can you think of a way to check if the command was successful?

Likely invalid or redundant comment.

deploy/docker/fs/opt/appsmith/pg-utils.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@abhvsn abhvsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment.

@AnaghHegde AnaghHegde requested a review from abhvsn October 7, 2024 09:35
@AnaghHegde AnaghHegde requested a review from abhvsn October 7, 2024 09:42
@AnaghHegde AnaghHegde enabled auto-merge (squash) October 7, 2024 10:01
@abhvsn abhvsn disabled auto-merge October 7, 2024 10:09
@AnaghHegde AnaghHegde merged commit d49ec24 into release Oct 7, 2024
42 checks passed
@AnaghHegde AnaghHegde deleted the chore/pg-create-extension branch October 7, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants