Feature request: idempotent schema migrations
See original GitHub issueHi folks, I love this library, and I’m trying to get it running in a project that uses Flyway for schema migrations.
I’ve managed to get it to work by migrating the DB to procrastinate, and then using Flyway to baseline and then migrate the schema over the top of it.
However, for the app, the Flyway migrations run every time the app starts, to ensure that the DB is always aligned to the app’s code. To force Procrastinate to work in the say way, I’m running procrastinate --app=tutorial.app schema --apply 2>&1 || true
in my startup command to force success, even when it errors with:
Applying schema
Error:
Database error.
type "procrastinate_job_status" already exists
Ideally I’d love procrastinate schema --apply
(or a different command) to succeed if the procrastinate tables already exist as-expected in the Postgres schema, and migrate them if not. Is that possible?
Thanks again!
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
Thanks for letting me know. I got it all working by integrating this file with my user-defined Flyway migrations, and running it as one process. Cheers!
In a word, yes.
schema.sql describes the final schema. The migration files describe, version by version, how to go from the schema of the previous version to the schema of the current version. They won’t give you the exact schema because the migrations also need to handle details like backwards compat, but it’s mostly the same.
https://procrastinate.readthedocs.io/en/stable/howto/migrations.html