groundhog-0.1.0.1: 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 typ Source

Constructors

Column 

Instances

Eq typ => Eq (Column typ) 
Show typ => Show (Column typ) 

data UniqueDef' Source

Constructors

UniqueDef' String [String] 

Instances

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

Foreign table name and names of the corresponding columns

data TableInfo typ Source

Constructors

TableInfo 

Fields

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

constraint name and reference

Instances

Show typ => Show (TableInfo typ) 

data AlterDB typ Source

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 

Instances

Show typ => Show (AlterDB typ) 

data MigrationPack m typ Source

Constructors

MigrationPack 

Fields

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

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

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

mkColumns :: (DbType -> typ) -> String -> DbType -> ([Column typ], [Reference])Source

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