-
Notifications
You must be signed in to change notification settings - Fork 39
fix(db): mechanism for db provisioning/migrations (PXP-7918) #80
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
Conversation
scripts/postgres_setup.sh
Outdated
@@ -0,0 +1,33 @@ | |||
#!/usr/bin/env bash |
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.
This all feels a bit hokey, but (after some searching) I found there is no mainline way out-of-the-box to set up a simple "run this script at startup" process for postgres' docker image so I created a custom entrypoint/command here to accomplish the task of setting up DBs and doing other DB work to orchestrate data as needed.
scripts/postgres_setup.sh
Outdated
set -e | ||
|
||
# Initialize the DB, but don't allow outside connections yet. | ||
docker-entrypoint.sh postgres -c listen_addresses='127.0.0.1' & |
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.
This relates to running the script after the init scripts but before the DB is accessible to other apps on the network. That distinction is significant because our apps (mostly) wait for the DB to be available and once it's online they get to work.
scripts/postgres_setup.sh
Outdated
# Run migrations/scripts that should run on every start. This is handy for data | ||
# we want to backfill or otherwise migrate for users. | ||
gosu postgres bash -c "( | ||
source /usr/local/bin/docker-entrypoint.sh |
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.
Official maintainers have considered that users like us may want this sort of behavior where we can run migrations or other scripts against Postgres and have done some work that allows us to hook into their entrypoint and create our own for this sort of behavior.
I will happily take in any/all suggestions for other ways to go about this sort of thing and re-think the implementation if this doesn't seem ideal. 🙇 These are some alternatives I was thinking about...
|
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.
😄
Jira Ticket: PXP-7918
New Features
Bug Fixes