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
- specify the list of unsafe migrations to be run (and add to it over time)
- get the entire list from
runMigrationWithEditUpdate's hook
- 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])
It looks like the workhorse is
runMigrationWithEditUpdate(is it intended thattryRunMigrationsWithEditUpdatedoesn'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
runMigrationWithEditUpdate's hookIs 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])