Skip to content

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

Open
@alexfmpe

Description

@alexfmpe

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])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions