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

How to reliably combine unsafe/manual migrations with safe/automatic ones? #20

Open
alexfmpe opened this issue Mar 11, 2021 · 0 comments

Comments

@alexfmpe
Copy link
Contributor

It looks like the workhorse is runMigrationWithEditUpdate (is it intended that tryRunMigrationsWithEditUpdate doesn't specify a hook?), but it can be tricky to figure out how to encode things so that migrating from commit A to commit B will work regardless of whether it's done commit-by-commit (e.g. dev) or in one go (e.g. a deployment).

It looks like the idea is something like

  1. specify the list of unsafe migrations to be run (and add to it over time)
  2. get the entire list from runMigrationWithEditUpdate's hook
  3. look at whether the subsequence of unsafe ones it's trying to do is a suffix of those you specified (i.e. we're in a state where any number of them might not be needed anymore, and all the ones after are needed), bail if that's not the case, then individually check that they're happening under the expected conditions, so you don't drop columns with data unless you opt-in, say, because you just converted/migrated that column.

Is this a reliable encoding? And if so, would it be worth adding a specialized helper for discoverability? Something like migrationHookFromExpectedUnsafe :: [(EditAction, EditCondition)] -> ([WithPriority Edit] -> [WithPriority Edit])

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

1 participant