-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add SQL-based migration script, with migration dir #878
Conversation
@spwoodcock this looks good. By the way, have you added this in the documentation too. If not, shall I give it a go. |
Thanks for the reminder about docs 👍 I'll update before I merge & include info on running manually during development (during deploy to different environments this will be handled automatically). Option 1 is like you say: Option 2: Option 3: Make sure you have the 4 env vars for the database connection set on your machine, then: bash src/backend/migrate-entrypoint.sh |
Issue
alembic
, but the setup is too complex for our needs and it's a bit of a black box.Solution
I have made a migration bash script, that is bundled with the backend.
The way it works:
src/backend/migrations
dir.000-remove-user-password.sql
:migrations
, which simply tracks the script name and execution date.migrations
directory is scanned for new files, and if there is no record in the database of being applied, the migration is applied.Note
I also lazily bundled a quick fix for the CI backend docker image build in this PR.
tl;dr
Create a
.sql
script undersrc/backend/migrations
and it will be applied when the backend next starts.