Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- data DropTableMode
- data MigrationAction m
- = StandardMigration (m ())
- | DropTableMigration DropTableMode
- | CreateIndexConcurrentlyMigration (RawSQL ()) TableIndex
- | DropIndexConcurrentlyMigration (RawSQL ()) TableIndex
- | forall t.FromRow t => ModifyColumnMigration (RawSQL ()) SQL ([t] -> m ()) Int
- data Migration m = Migration {
- mgrTableName :: RawSQL ()
- mgrFrom :: Int32
- mgrAction :: MigrationAction m
- isStandardMigration :: Migration m -> Bool
- isDropTableMigration :: Migration m -> Bool
Documentation
data DropTableMode Source #
Whether to also drop objects that depend on the table.
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. |
data MigrationAction m Source #
Migration action to run, either an arbitrary MonadDB
action, or
something more fine-grained.
StandardMigration (m ()) | Standard migration, i.e. an arbitrary |
DropTableMigration DropTableMode | Drop table migration. Parameter is the drop table mode
( |
CreateIndexConcurrentlyMigration | Migration for creating an index concurrently. |
| |
DropIndexConcurrentlyMigration | Migration for dropping an index concurrently. |
| |
forall t.FromRow t => ModifyColumnMigration (RawSQL ()) SQL ([t] -> m ()) Int | Migration for modifying columns. Parameters are: Name of the table that the cursor is associated with. It has to be the same as in the cursor SQL, see the second parameter. SQL providing a list of primary keys from the associated table that will be used for the cursor. Function that takes a batch of primary keys provided by the cursor SQL and runs an arbitrary computation within MonadDB. The function might be called repeatedly depending on the batch size and total number of selected primary keys. See the last argument. Batch size of primary keys to be fetched at once by the cursor SQL and be given to the modification function. To handle multi-column primary keys, the following needs to be done:
|
Migration object.
Migration | |
|
isStandardMigration :: Migration m -> Bool Source #
isDropTableMigration :: Migration m -> Bool Source #