HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleselda-0.5.2.1Haskell2010

Database.Selda.Migrations

Functionality for upgrading a table from one schema to another.

  • 1 type
  • 4 values
  • Packageselda-0.5.2.1
  • Exports5
  • LanguageHaskell2010
  • LicenceMIT
  • SourceMigrations.hs
valuemigrate
  1. :: (MonadSelda m, MonadMask m, Relational a, Relational b)
  2. => Table a

    Table to migrate from.

  3. -> Table b

    Table to migrate to.

  4. -> (Row (Backend m) a -> Row (Backend m) b)

    Mapping from old to new table.

  5. -> m ()
#

Migrate the first table into the second, using the given function to migrate all records to the new schema. Both table schemas are validated before starting the migration, and the source table is validated against what's currently in the database.

The migration is performed as a transaction, ensuring that either the entire migration passes, or none of it does.

valuemigrateAll
  1. :: (MonadSelda m, MonadMask m)
  2. => Bool

    Enforce foreign keys during migration?

  3. -> MigrationStep (Backend m)

    Migration step to perform.

  4. -> m ()
#

Perform all given migrations as a single transaction.

valueautoMigrate
  1. :: (MonadSelda m, MonadMask m)
  2. => Bool

    Enforce foreign keys during migration?

  3. -> [MigrationStep (Backend m)]

    Migration steps to perform.

  4. -> m ()
#

Given a list of migration steps in ascending chronological order, finds the latest migration step starting state that matches the current database, and performs all migrations from that point until the end of the list. The whole operation is performed as a single transaction.

If no matching starting state is found, a ValidationError is thrown. If the database is already in the state specified by the end state of the final step, no migration is performed.

Note that when looking for a matching starting state, index methods for indexed columns are not taken into account. Two columns c1 and c2 are considered to be identical if c1 is indexed with index method foo and c2 is indexed with index method bar.