Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 postgres #36591
chore: create appsmith schema for postgres #36591
Changes from all commits
598ef61
62fb7d2
76e95c3
d89a596
1edfc6f
1413b1e
cb4a295
833832d
ca8d57a
65ea2db
d3bf74c
0254049
bca4afc
846a63b
43089a6
342e4d4
80da201
14a0f35
d38ca4d
32f91e8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Class, let's examine the URL validation and host determination.
Good effort on validating the APPSMITH_DB_URL! However, we can improve this section:
"$APPSMITH_DB_URL" == postgres*://*
might not catch all valid PostgreSQL URLs. Let's use a more robust regex pattern.Here's a suggested improvement:
This change will catch more valid PostgreSQL URLs and include the IPv6 localhost address. Remember, students, attention to detail is crucial in database management!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, let's turn our attention to the local database and schema creation, class.
You've done a good job structuring the database and schema creation logic. However, there are a few points we need to address:
Excellent use of conditional checks before creating the database and schema!
Be cautious about potential SQL injection in the database name. Let's sanitize it:
PG_DB_NAME=$(echo "$PG_DB_NAME" | sed 's/[^a-zA-Z0-9_]//g')
There's a syntax error in the user creation SQL. The username should not be in double quotes. Let's fix that:
It's generally not a good practice to log passwords, even partially. Let's remove that from the echo statement on line 116.
Consider adding error handling for each psql command to ensure the script exits if any operation fails.
Remember, class, security and error handling are crucial in database management scripts!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Now, let's examine the remote host schema creation, students.
While this section is concise, there are a few important points we need to address:
Using PGPASSWORD in the command line is not the most secure method. However, for scripts, it's acceptable. Just ensure this script is only accessible to authorized users.
We're missing error handling here. Let's add some:
Consider using a connection timeout to prevent the script from hanging indefinitely:
PGCONNECT_TIMEOUT=10 PGPASSWORD=$PG_DB_PASSWORD psql ...
Remember, class, always think about error handling and timeouts when dealing with remote connections!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Finally, let's review the schema creation verification, class.
This section shows good attention to error handling, but we can make it even better:
The success message could be more specific. Instead of just saying the schema exists, let's confirm it:
Let's add a final check to ensure the user has the necessary permissions:
Remember, students, thorough verification and clear error messages are key to maintaining a robust system!