-
Notifications
You must be signed in to change notification settings - Fork 293
Closed
Description
sql-migrate behaves badly when the database has migrations "unknown" to the current run of sql-migrate. This is most likely to happen when a diverged branch applied its migrations to a database while another branch also applied its own migrations to a database.
For example:
- branch A: 1, 2, 3
- branch B: 1, 2, 4
- branch B applies against DB. State is now "1, 2, 4"
- branch A tries to apply against DB. Migration "4" is unknown.
See existing issue: #37
How should sql-migrate behave when asked to perform a migration against a database that has unknown migrations? I can think of two reasonable behaviors:
- Complain that unknown migrations exist. Require the user to pass a -f force flag to complete the migrations. I'm not sure how the library should change, but I could work up some suggestions.
- Do the best we can. When migrating up, ignore the unknown migrations. When migrating down, fail upon encountering an unknown migration.
(For option 2, we could also allow migrating down by adding a migrate_down column to the migrations table and storing the SQL at migrate up time. That doesn't help any existing installations, but would be a way forward.)
Which behavior seems best? I'm in favor of 2, but see the merits of 1.
Metadata
Metadata
Assignees
Labels
No labels