hpqtypes-extras-1.6.1.0: Extra utilities for hpqtypes library

Database.PostgreSQL.PQTypes.Model.Migration

Description

Using migrations is fairly easy. After you've defined the lists of migrations and tables, just run migrateDatabase:

tables :: [Table]
tables = ...

migrations :: [Migration]
migrations = ...

migrateDatabase options extensions domains tables migrations


Migrations are run strictly in the order specified in the migrations list, starting with the first migration for which the corresponding table in the DB has the version number equal to the mgrFrom field of the migration.

Synopsis

# Documentation

Whether to also drop objects that depend on the table.

Constructors

 DropTableCascade Automatically drop objects that depend on the table (such as views). DropTableRestrict Refuse to drop the table if any objects depend on it. This is the default.

Migration action to run, either an arbitrary MonadDB action, or something more fine-grained.

Constructors

 StandardMigration (m ()) Standard migration, i.e. an arbitrary MonadDB action. DropTableMigration DropTableMode Drop table migration. Parameter is the drop table mode (RESTRICT/CASCADE). The Migration record holds the name of the table to drop.

data Migration m Source #

Migration object.

Constructors

 Migration FieldsmgrTableName :: RawSQL ()The name of the table you're migrating.mgrFrom :: Int32The version you're migrating *from* (you don't specify what version you migrate TO, because version is always increased by 1, so if mgrFrom is 2, that means that after that migration is run, table version will equal 3mgrAction :: MigrationAction mMigration action.