groundhog-0.8.0.1: 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 #

Instances

Eq Column # 

Methods

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

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

Show Column # 

type QualifiedName = (Maybe String, String) #

Schema-qualified name of a table of another database object

data TableInfo #

Constructors

TableInfo 

Fields

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

Either column name or expression

data AlterDB #

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

class PersistBackendConn conn => SchemaAnalyzer conn where #

Methods

schemaExists #

Arguments

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

Schema name

-> m Bool 

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

listTables #

Arguments

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

Schema name

-> m [String] 

listTableTriggers #

Arguments

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

Qualified table name

-> m [String] 

analyzeTable #

Arguments

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

Qualified table name

-> m (Maybe TableInfo) 

analyzeTrigger #

Arguments

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

Qualified trigger name

-> m (Maybe String) 

analyzeFunction #

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

migrateRecursively #

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 #

Arguments

:: MigrationPack m 
-> TableInfo

From database

-> TableInfo

From datatype

-> [AlterTable]