rubenv / sql-migrate

SQL schema migration tool for Go.
MIT License
3.18k stars 270 forks source link

Add a flag to allow including missing migrations #190

Closed nacx closed 3 years ago

nacx commented 3 years ago

Adds a way to include missing migrations in the migration plan (keeping the current behavior as the default one).

This change allows different migration sets to coexist, for example when building a migration plan based on migrations from different projects. For example, if composing a migration plan with the following migrations taken from different folders/folders:

projectA
   /migrationsA
        001_A-schema.sql
        002_A-data.sql
projectB
   /migrationsB
        001_B-schema.sql
        002_B-data.sql

The migrations in B would never be included if the ones in A were already applied because given the numbering prefix they would be considered older.

This PR adds the IncldueMissing flag, to allow including always missing migrations, without checking if those missing ones are older than other existing ones.

nacx commented 3 years ago

Closing for now... this should be better achieved by installing the migrations in different tables.