| Safe Haskell | None |
|---|
Database.Groundhog.Generic.Migration
Description
This helper module is intended for use by the backend creators
- data Column = Column {}
- data UniqueDef' = UniqueDef' String UniqueType [String]
- type Reference = (String, [(String, String)])
- data TableInfo = TableInfo {
- tablePrimaryKeyName :: Maybe String
- tableColumns :: [Column]
- tableUniques :: [UniqueDef']
- tableReferences :: [(Maybe String, Reference)]
- data AlterColumn
- type AlterColumn' = (String, AlterColumn)
- data AlterTable
- data AlterDB
- data MigrationPack m = MigrationPack {
- compareTypes :: DbType -> DbType -> Bool
- compareRefs :: (Maybe String, Reference) -> (Maybe String, Reference) -> Bool
- compareUniqs :: UniqueDef' -> UniqueDef' -> Bool
- checkTable :: String -> m (Maybe (Either [String] TableInfo))
- migTriggerOnDelete :: String -> [(String, String)] -> m (Bool, [AlterDB])
- migTriggerOnUpdate :: String -> String -> String -> m (Bool, [AlterDB])
- migConstr :: MigrationPack m -> Bool -> String -> ConstructorDef -> m (Bool, SingleMigration)
- escape :: String -> String
- primaryKeyType :: String
- foreignKeyType :: String
- mainTableId :: String
- defaultPriority :: Int
- addUniquesReferences :: [UniqueDef'] -> [Reference] -> ([String], [AlterTable])
- showColumn :: Column -> String
- showAlterDb :: AlterDB -> SingleMigration
- mkColumns :: (DbType -> DbType) -> String -> DbType -> ([Column], [Reference])
- migrateRecursively :: (Monad m, PersistEntity v) => (EntityDef -> m SingleMigration) -> (DbType -> m SingleMigration) -> v -> StateT NamedMigrations m ()
- migrateEntity :: Monad m => MigrationPack m -> EntityDef -> m SingleMigration
- migrateList :: Monad m => MigrationPack m -> DbType -> m SingleMigration
- getAlters :: MigrationPack m -> TableInfo -> TableInfo -> [AlterTable]
- defaultMigConstr :: Monad m => MigrationPack m -> 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 | |
| Drop | |
| AddPrimaryKey | |
| Default String | |
| NoDefault | |
| UpdateValue String |
Instances
type AlterColumn' = (String, AlterColumn)Source
data AlterTable Source
Constructors
| AddUnique UniqueDef' | |
| DropConstraint String | |
| DropIndex String | |
| AddReference Reference | |
| DropReference String | |
| AlterColumn AlterColumn' |
Instances
Constructors
| AddTable String | |
| AlterTable String String TableInfo TableInfo [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 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 => MigrationPack m -> EntityDef -> m SingleMigrationSource
migrateList :: Monad m => MigrationPack m -> DbType -> m SingleMigrationSource
getAlters :: MigrationPack m -> TableInfo -> TableInfo -> [AlterTable]Source
defaultMigConstr :: Monad m => MigrationPack m -> Bool -> String -> ConstructorDef -> m (Bool, SingleMigration)Source