groundhog-0.2.0: Type-safe ADT-database mapping library.

Safe HaskellNone

Database.Groundhog.Generic.Migration

Description

This helper module is intended for use by the backend creators

Synopsis

Documentation

data Column Source

Constructors

Column 

Instances

type Reference = (String, [(String, String)])Source

Foreign table name and names of the corresponding columns

data TableInfo Source

Constructors

TableInfo 

Fields

tablePrimaryKeyName :: Maybe String
 
tableColumns :: [Column]
 
tableUniques :: [UniqueDef']
 
tableReferences :: [(Maybe String, Reference)]

constraint name and reference

Instances

data AlterDB Source

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 

Instances

data MigrationPack m Source

Constructors

MigrationPack 

Fields

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])

Sql pieces for the create table statement that add constraints and alterations for running after the table is created

showColumn :: Column -> String
 
showAlterDb :: AlterDB -> SingleMigration
 

migrateRecursivelySource

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