mzabani / codd

Codd is a simple-to-use CLI tool that applies plain postgres SQL migrations atomically with strong and automatic cross-environment schema equality checks.
Other
38 stars 1 forks source link

Allow dumps with `codd_schema` as migrations #189

Closed mzabani closed 3 months ago

mzabani commented 7 months ago

Right now codd will create codd_schema before the first migration with the default connection string, meaning a dump that is used as a migration will also try to create codd_schema and fail. Because of that, only dumps that don't contain codd_schema can be used, but those make things complicated as users have to delete every migration they know to be in that dump, which isn't easy if you're e.g. restoring a dump from a Staging or Prod environment taken somewhere in time.

If it's possible without any downsides to atomicity of registering migrations to delay the creation of codd_schema sufficiently such that we can restore a dump that also contains codd_schema, this would make life much easier for users of codd.

mzabani commented 7 months ago

This is, as usual, trickier than it sounded. Codd needs to check after each migration it applies if the list of applied migrations has changed, and skip migrations that had been previously part of the set of pending ones.