| Safe Haskell | None |
|---|
Database.Groundhog.Generic.Migration
Description
This helper module is intended for use by the backend creators
- data Column typ = Column {}
- data UniqueDef' = UniqueDef' String [String]
- type Reference = (String, [(String, String)])
- data TableInfo typ = TableInfo {
- tablePrimaryKeyName :: Maybe String
- tableColumns :: [Column typ]
- tableUniques :: [UniqueDef']
- tableReferences :: [(Maybe String, Reference)]
- data AlterColumn
- type AlterColumn' = (String, AlterColumn)
- data AlterTable
- data AlterDB typ
- data MigrationPack m typ = MigrationPack {
- compareColumns :: Column typ -> Column DbType -> Bool
- compareRefs :: (Maybe String, Reference) -> (Maybe String, Reference) -> Bool
- compareUniqs :: UniqueDef' -> UniqueDef' -> Bool
- checkTable :: String -> m (Maybe (Either [String] (TableInfo typ)))
- migTriggerOnDelete :: String -> [(String, String)] -> m (Bool, [AlterDB typ])
- migTriggerOnUpdate :: String -> String -> String -> m (Bool, [AlterDB typ])
- migConstr :: MigrationPack m typ -> Bool -> String -> ConstructorDef -> m (Bool, SingleMigration)
- escape :: String -> String
- primaryKeyType :: String
- foreignKeyType :: String
- mainTableId :: String
- defaultPriority :: Int
- convertType :: DbType -> typ
- addUniquesReferences :: [UniqueDef'] -> [Reference] -> ([String], [AlterTable])
- showColumn :: Column DbType -> String
- showAlterDb :: AlterDB typ -> SingleMigration
- mkColumns :: (DbType -> typ) -> String -> DbType -> ([Column typ], [Reference])
- migrateRecursively :: (Monad m, PersistEntity v) => (EntityDef -> m SingleMigration) -> (DbType -> m SingleMigration) -> v -> StateT NamedMigrations m ()
- migrateEntity :: (Monad m, Show typ) => MigrationPack m typ -> EntityDef -> m SingleMigration
- migrateList :: (Monad m, Show typ) => MigrationPack m typ -> DbType -> m SingleMigration
- getAlters :: (Eq typ, Show typ) => MigrationPack m typ -> TableInfo typ -> TableInfo DbType -> [AlterTable]
- defaultMigConstr :: (Monad m, Eq typ, Show typ) => MigrationPack m typ -> Bool -> String -> ConstructorDef -> m (Bool, SingleMigration)
Documentation
Constructors
| Column | |
type Reference = (String, [(String, String)])Source
Foreign table name and names of the corresponding columns
Constructors
| TableInfo | |
Fields
| |
data AlterColumn Source
Constructors
| Type DbType | |
| IsNull | |
| NotNull | |
| Add (Column DbType) | |
| Drop | |
| AddPrimaryKey | |
| Default String | |
| NoDefault | |
| UpdateValue String |
Instances
type AlterColumn' = (String, AlterColumn)Source
data AlterTable Source
Constructors
| AddUniqueConstraint String [String] | |
| DropConstraint String | |
| AddReference Reference | |
| DropReference String | |
| AlterColumn AlterColumn' |
Instances
Constructors
| AddTable String | |
| AlterTable String String (TableInfo typ) (TableInfo DbType) [AlterTable] | Table name, create statement, structure of table from DB, structure of table from datatype, alters |
| DropTrigger String String | Trigger name, table name |
| AddTriggerOnDelete String String String | Trigger name, table name, body |
| AddTriggerOnUpdate String String String String | Trigger name, table name, field name, body |
| CreateOrReplaceFunction String | |
| DropFunction String |
data MigrationPack m typ Source
Constructors
| MigrationPack | |
Fields
| |
Arguments
| :: (Monad m, PersistEntity v) | |
| => (EntityDef -> m SingleMigration) | migrate entity |
| -> (DbType -> m SingleMigration) | migrate list |
| -> v | initial entity |
| -> StateT NamedMigrations m () |
Create migration for a given entity and all entities it depends on. The stateful Map is used to avoid duplicate migrations when an entity type occurs several times in a datatype
migrateEntity :: (Monad m, Show typ) => MigrationPack m typ -> EntityDef -> m SingleMigrationSource
migrateList :: (Monad m, Show typ) => MigrationPack m typ -> DbType -> m SingleMigrationSource
getAlters :: (Eq typ, Show typ) => MigrationPack m typ -> TableInfo typ -> TableInfo DbType -> [AlterTable]Source
defaultMigConstr :: (Monad m, Eq typ, Show typ) => MigrationPack m typ -> Bool -> String -> ConstructorDef -> m (Bool, SingleMigration)Source