Safe Haskell | None |
---|
This helper module is intended for use by the backend creators
- data Column = Column {}
- data UniqueDef' = UniqueDef' {}
- data Reference = Reference {}
- data TableInfo = TableInfo {
- tableColumns :: [Column]
- tableUniques :: [UniqueDef']
- tableReferences :: [(Maybe String, Reference)]
- data AlterColumn
- data AlterTable
- data AlterDB
- = AddTable String
- | AlterTable (Maybe String) String String TableInfo TableInfo [AlterTable]
- | DropTrigger (Maybe String) String (Maybe String) String
- | AddTriggerOnDelete (Maybe String) String (Maybe String) String String
- | AddTriggerOnUpdate (Maybe String) String (Maybe String) String (Maybe String) String
- | CreateOrReplaceFunction String
- | DropFunction (Maybe String) String
- data MigrationPack m = MigrationPack {
- compareTypes :: DbType -> DbType -> Bool
- compareRefs :: (Maybe String, Reference) -> (Maybe String, Reference) -> Bool
- compareUniqs :: UniqueDef' -> UniqueDef' -> Bool
- migTriggerOnDelete :: Maybe String -> String -> [(String, String)] -> m (Bool, [AlterDB])
- migTriggerOnUpdate :: Maybe String -> String -> [(String, String)] -> m [(Bool, [AlterDB])]
- migConstr :: MigrationPack m -> EntityDef -> ConstructorDef -> m (Bool, SingleMigration)
- escape :: String -> String
- primaryKeyType :: DbType
- primaryKeyTypeName :: String
- foreignKeyTypeName :: String
- mainTableId :: String
- defaultPriority :: Int
- addUniquesReferences :: [UniqueDef'] -> [Reference] -> ([String], [AlterTable])
- showColumn :: Column -> String
- showAlterDb :: AlterDB -> SingleMigration
- class SchemaAnalyzer m where
- mkColumns :: String -> DbType -> ([Column], [Reference])
- migrateRecursively :: (Monad m, PersistEntity v) => (EntityDef -> m SingleMigration) -> (DbType -> m SingleMigration) -> v -> StateT NamedMigrations m ()
- migrateEntity :: (Monad m, SchemaAnalyzer m) => MigrationPack m -> EntityDef -> m SingleMigration
- migrateList :: (Monad m, SchemaAnalyzer m) => MigrationPack m -> DbType -> m SingleMigration
- getAlters :: MigrationPack m -> TableInfo -> TableInfo -> [AlterTable]
- defaultMigConstr :: (Monad m, SchemaAnalyzer m) => MigrationPack m -> EntityDef -> ConstructorDef -> m (Bool, SingleMigration)
- showReferenceAction :: ReferenceActionType -> String
- readReferenceAction :: String -> Maybe ReferenceActionType
Documentation
data UniqueDef' Source
Reference | |
|
TableInfo | |
|
data AlterColumn Source
data AlterTable Source
AddTable String | |
AlterTable (Maybe String) String String TableInfo TableInfo [AlterTable] | Table schema, table name, create statement, structure of table from DB, structure of table from datatype, alters |
DropTrigger (Maybe String) String (Maybe String) String | Trigger schema, trigger name, table schema, table name |
AddTriggerOnDelete (Maybe String) String (Maybe String) String String | Trigger schema, trigger name, table schema, table name, body |
AddTriggerOnUpdate (Maybe String) String (Maybe String) String (Maybe String) String | Trigger schema, trigger name, table schema, table name, field name, body |
CreateOrReplaceFunction String | Statement which creates the function |
DropFunction (Maybe String) String | Function schema, function name |
data MigrationPack m Source
MigrationPack | |
|
class SchemaAnalyzer m whereSource
:: (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, SchemaAnalyzer m) => MigrationPack m -> EntityDef -> m SingleMigrationSource
migrateList :: (Monad m, SchemaAnalyzer m) => MigrationPack m -> DbType -> m SingleMigrationSource
:: MigrationPack m | |
-> TableInfo | From database |
-> TableInfo | From datatype |
-> [AlterTable] |
defaultMigConstr :: (Monad m, SchemaAnalyzer m) => MigrationPack m -> EntityDef -> ConstructorDef -> m (Bool, SingleMigration)Source