Closed saulius closed 11 years ago
we would only need migrations to rewrite history, e.g add in missing data, so not too fussed about that.
But could you elaborate on the second point, what's the issue there? If we change the schema the migration will fail? Whitehall suffers from models changes, where past migrations are just broken, so commenting out is an option, but i'm not sure I understand if that the issue you're raising.
What should we do about old migration files that cover data changes, e.g. https://github.com/alphagov/trade-tariff-backend/blob/master/db/migrate/20130418141944_change_footnote_04003.rb ? These are now duplicated in data migrations and I would actually want to not run them with schema changes, so should I comment them and keep the files?
Hrm.. sounds like we should move them into data migrations, delete the old migrations, and then repopulate the db, unless they cannot be run twice, I dont see the issue, otherwise we would need to reload the db.
So they are already in data migrations. I cannot delete the files because they are in schema_migrations table and Sequel will then complain before each run. So I'm thinking perhaps just comment out their content for now so #up
and #down
are empty?
If we need to reload the db anyway, can we remove and recreate the db? If not then commenting out is fine.
Ah yes, we can remove them if we will be reloading anyway. I will update the pull request and ping you.
@matthewford I pushed a few commits that remove data related migrations for schema migrations all together. But with these changes we will now definitely need to reload the snapshot.
Right, merging with the view we do a full reload.
This change is for https://www.pivotaltracker.com/story/show/43132661
Separates schema migrations from data migrations, as schema migrations with data are usually problematic when we're recreating database snapshot from scratch. They fill in data before Taric and CHIEF imports and that can cause integrity issues later. Data migrations should be run after all schema changes and data imports are applied.
This adds several new rake commands:
Check current db state:
Rollback last applied migration (based on timestamp in filename):
Apply all pending migrations:
Rollback and apply last migration:
Things to note/questions: