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 appsmith schema for the pg branch with user and password #36540

Closed
wants to merge 5 commits into from

Conversation

AnaghHegde
Copy link
Member

@AnaghHegde AnaghHegde commented Sep 25, 2024

Description

Create schema for the pg used by Appsmith. The default public schema can cause issues and creating a new schema allows us to have isolation with the other data in pg. This also creates a user and password which is used to access the schema.

Automation

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

🔍 Cypress test results

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11051541656
Commit: 973dabf
Cypress dashboard.
Tags: @tag.Sanity
Spec:
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js
List of identified flaky tests.
Thu, 26 Sep 2024 12:13:36 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced automatic initialization of the PostgreSQL database schema for improved setup.
    • Enhanced handling of database credentials with defaults for user and password.
  • Bug Fixes

    • Improved logging for schema creation success or failure.

Copy link
Contributor

coderabbitai bot commented Sep 25, 2024

Walkthrough

The changes enhance the init_postgres function in the entrypoint.sh script, focusing on initializing a PostgreSQL database schema named "appsmith." It includes validation of the APPSMITH_DB_URL environment variable to ensure it is a valid PostgreSQL URL. The function extracts necessary credentials, provides defaults for missing values, and attempts to create the schema if it does not already exist, logging the outcome of this operation.

Changes

File Path Change Summary
deploy/docker/fs/opt/appsmith/entrypoint.sh Modified init_postgres() to initialize "appsmith" schema in PostgreSQL, validating and extracting credentials from APPSMITH_DB_URL, with defaults for missing values.

Possibly related PRs

Suggested reviewers

  • abhvsn
  • sharat87

Poem

In the realm of code where databases play,
A schema called "appsmith" is born today.
With URLs checked and defaults in sight,
PostgreSQL welcomes its new data light.
So raise up your scripts, let the logging commence,
For a world of new data, we now can dispense! 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b67064d and 973dabf.

📒 Files selected for processing (1)
  • deploy/docker/fs/opt/appsmith/entrypoint.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • deploy/docker/fs/opt/appsmith/entrypoint.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 requested review from abhvsn and removed request for sharat87 September 25, 2024 12:35
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Sep 25, 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: 4

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2f2f5a6 and cd8e70d.

📒 Files selected for processing (1)
  • deploy/docker/fs/opt/appsmith/entrypoint.sh (1 hunks)
🧰 Additional context used
Shellcheck
deploy/docker/fs/opt/appsmith/entrypoint.sh

[error] 469-469: Couldn't parse this here document. Fix to allow more checks.

(SC1073)


[error] 471-471: Remove indentation before end token (or use <<- and indent with tabs).

(SC1039)

@AnaghHegde AnaghHegde added the ok-to-test Required label for CI label Sep 25, 2024
@appsmithorg appsmithorg deleted a comment from coderabbitai bot Sep 26, 2024
@appsmithorg appsmithorg deleted a comment from coderabbitai bot Sep 26, 2024
@appsmithorg appsmithorg deleted a comment from coderabbitai bot Sep 26, 2024
@appsmithorg appsmithorg deleted a comment from coderabbitai bot Sep 26, 2024
echo "Initializing PostgreSQL..."

# Check if APPSMITH_DB_URL is a PostgreSQL URL
if [[ -n "$APPSMITH_DB_URL" && "$APPSMITH_DB_URL" == postgres*://* ]]; then
Copy link
Contributor

@abhvsn abhvsn Sep 26, 2024

Choose a reason for hiding this comment

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

As of now the entrupoint script which is responsible for creating an env file is starting with MongoDB url. How are we testing this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am testing this on the pg branch.

echo "Connecting to PostgreSQL at $DB_HOST:$DB_PORT with user $DB_USER"

# Execute SQL to create the appsmith schema if it doesn't exist (single line)
PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c "CREATE SCHEMA IF NOT EXISTS appsmith;"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also create a separate user in case of embedded Postgres DB alongwith the password.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean by separate user for embeded db? The user is hardcoded to appsmith when the username or password is empty

Copy link
Contributor

Choose a reason for hiding this comment

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

I was referring to create user statement, you can find more details https://www.postgresql.org/docs/8.0/sql-createuser.html

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.

Added few comments, but I'm of the opinion if you make these changes on pg branch and then port it here it will be easier to test these changes.

@AnaghHegde AnaghHegde changed the base branch from release to pg September 26, 2024 11:56
@AnaghHegde AnaghHegde requested a review from a team as a code owner September 26, 2024 11:56
@AnaghHegde AnaghHegde changed the base branch from pg to release September 26, 2024 11:57
@KelvinOm KelvinOm removed request for a team September 27, 2024 11:06
@AnaghHegde AnaghHegde closed this Sep 27, 2024
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