Skip to content
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

checksum migrations (repeatable migrations) #310

Open
zy4 opened this issue Nov 27, 2019 · 1 comment
Open

checksum migrations (repeatable migrations) #310

zy4 opened this issue Nov 27, 2019 · 1 comment

Comments

@zy4
Copy link

zy4 commented Nov 27, 2019

Is this possibly a feature which others want to see in here as well?
The idea is to keep the migration file count small when there will be
frequent changes to views, functions or bulk data inserts.

Tracking and undoing migrations in this case would be handled by version control only.

Here is an example of this concept: https://flywaydb.org/documentation/concepts/migrations.html#repeatable-migrations

@dhui
Copy link
Member

dhui commented Jan 3, 2020

That's an interesting idea for creating reference data, functions, views, etc

Quoting relevant content in case the link above changes:

Repeatable migrations have a description and a checksum, but no version. Instead of being run just once, they are (re-)applied every time their checksum changes.

This is very useful for managing database objects whose definition can then simply be maintained in a single file in version control. They are typically used for

  • (Re-)creating views/procedures/functions/packages/…
  • Bulk reference data reinserts

Within a single migration run, repeatable migrations are always applied last, after all pending versioned migrations have been executed. Repeatable migrations are applied in the order of their description.

It is your responsibility to ensure the same repeatable migration can be applied multiple times. This usually involves making use of CREATE OR REPLACE clauses in your DDL statements.

It'd be quite a bit of work to implement this in a backwards compatible manner. e.g. need to support old migration file names and migrate the schema version table.

See also: #179 and #278


EDIT:
Loading repeatable migrations from a different source and track them in a separate schema migrations table could make backwards compatibility easier to tackle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants