Domanda

db-maintain has the notion of repeatable scripts, such as stored procedures/triggers. When there is a change to such a script it needs to be rolled out again. Flyway seemingly always checks for the filename convention. So to have a repeatable script we might need to rename the file. Is there a more efficient way of doing this?

È stato utile?

Soluzione

Flyway started to support repeatable migrations in version 4.0. Repeatable migrations are reapplied every time their checksum changes and can be maintained as single files in version control.

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.

More details here.

Altri suggerimenti

This issue has come up in the Issue Tracker and in this other question.

There is currently no out of the box support for this.

Personally I would

  • package the repeatable actions in a stored procedure or trigger and add it to the DB as part of a regular migration
  • make sure this procedure/trigger gets invoked once per migration after that (could be as little a one-line statement)
  • ensure changes to the procedure/trigger necessary after that also happen as part of regular migrations

If that doesn't do it, feel free to star the Issue and comment with details about your use case.

Update: Repeatable scripts are now fully supported as of Flyway 4.0. See https://flywaydb.org/documentation/migration/repeatable

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top