groundhog-0.10.0: Type-safe datatype-database mapping library.

Safe HaskellNone
LanguageHaskell98

Database.Groundhog.Generic.Migration

Description

This helper module is intended for use by the backend creators

Synopsis

Documentation

data Column Source #

Instances
Eq Column Source # 
Instance details

Defined in Database.Groundhog.Generic.Migration

Methods

(==) :: Column -> Column -> Bool #

(/=) :: Column -> Column -> Bool #

Show Column Source # 
Instance details

Defined in Database.Groundhog.Generic.Migration

type QualifiedName = (Maybe String, String) Source #

Schema-qualified name of a table of another database object

data TableInfo Source #

Constructors

TableInfo 

Fields

type UniqueDefInfo = UniqueDef' String (Either String String) Source #

Either column name or expression

data AlterDB Source #

Constructors

AddTable String 
AlterTable QualifiedName String TableInfo TableInfo [AlterTable]

Qualified table name, create statement, structure of table from DB, structure of table from datatype, alters

DropTrigger QualifiedName QualifiedName

Qualified trigger name, qualified table name

AddTriggerOnDelete QualifiedName QualifiedName String

Qualified trigger name, qualified table name, body

AddTriggerOnUpdate QualifiedName QualifiedName (Maybe String) String

Qualified trigger name, qualified table name, field name, body

CreateOrReplaceFunction String

Statement which creates the function

DropFunction QualifiedName

Qualified function name

CreateSchema String Bool

Schema name, if not exists

Instances
Show AlterDB Source # 
Instance details

Defined in Database.Groundhog.Generic.Migration

class PersistBackendConn conn => SchemaAnalyzer conn where Source #

Methods

schemaExists Source #

Arguments

:: (PersistBackend m, Conn m ~ conn) 
=> String

Schema name

-> m Bool 

getCurrentSchema :: (PersistBackend m, Conn m ~ conn) => m (Maybe String) Source #

listTables Source #

Arguments

:: (PersistBackend m, Conn m ~ conn) 
=> Maybe String

Schema name

-> m [String] 

listTableTriggers Source #

Arguments

:: (PersistBackend m, Conn m ~ conn) 
=> QualifiedName

Qualified table name

-> m [String] 

analyzeTable Source #

Arguments

:: (PersistBackend m, Conn m ~ conn) 
=> QualifiedName

Qualified table name

-> m (Maybe TableInfo) 

analyzeTrigger Source #

Arguments

:: (PersistBackend m, Conn m ~ conn) 
=> QualifiedName

Qualified trigger name

-> m (Maybe String) 

analyzeFunction Source #

Arguments

:: (PersistBackend m, Conn m ~ conn) 
=> QualifiedName

Qualified function name

-> m (Maybe (Maybe [DbTypePrimitive], Maybe DbTypePrimitive, String))

Argument types, return type, and body

getMigrationPack :: (PersistBackend m, Conn m ~ conn) => m (MigrationPack conn) Source #

migrateRecursively Source #

Arguments

:: (PersistBackend m, PersistEntity v) 
=> (String -> m SingleMigration)

migrate schema

-> (EntityDef -> m SingleMigration)

migrate entity

-> (DbType -> m SingleMigration)

migrate list

-> v

initial entity

-> Migration 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

getAlters Source #

Arguments

:: MigrationPack m 
-> TableInfo

From database

-> TableInfo

From datatype

-> [AlterTable]