Safe Haskell | None |
---|---|
Language | Haskell2010 |
Implementation of Upgrades
Upgrades are tricky.
- DELETE statements must come first
Tables
TODO: Delete tables and columns if the user excplicitly agrees to data loss.
CREATE TABLE IF NOT EXISTS without any columns.
CREATE columns with their type on demand.
Always apply all ALTER COLUMN statments
- SET DATA TYPE
- DROP DEFAULT
- SET DEFAULT
- SET/DROP NOT NULL
TODO: Maybe bundle DROP/SET DEFAULT, such that they can't be reordered.
Constrs are completly dropped an recreated. Would be cool to create PKs first, to fix FK requirements right away.
Functions
Many things can depend on functions (column defaults, table and domain constraints). Therefore, they should all be deleted before deleting a function.
Usually CREATE OR REPLACE FUNCTION
is used, such that no deletions occure.
However, some function properties cannot be changed via CREATE OR REPLACE. A
known example this the change of the return type. In this case the
sqlErrInvalidFunctionDefinition
will be catched and the function is deleted
and created again.
Domains
Constrs are always deleted an recreated.
Defaults are always set explicitly.
Domains are deleted on demand.
The data type of a domain cannot be changed (at least in PostgreSQL).
TODO: Issue error if domain type differs.
Roles
Difficult since not schema qualified, but be have prefixes.
TODO: LOGIN and PASSWORD are not implemented via ALTER ROLE
TODO: Are role memberships revoked?
Sequences
CREATE only defines name on demand.
Properties all via ALTER SEQUENCE.
Documentation
pgsqlGetFullStatements :: OptCommon -> OptCommonDb -> Setup -> IO [SqlStmt] Source #
pgsqlDeleteAllStmt :: Connection -> IO [SqlStmt] Source #
pgsqlUpdateFragile :: Setup -> Connection -> [SqlStmt] -> IO [SqlStmt] Source #
pgsqlDropAllRoleStmts :: OptCommonDb -> Setup -> IO [SqlStmt] Source #
pgsqlExecWithoutTransact :: OptCommonDb -> URI -> [SqlStmt] -> IO Connection Source #
pgsqlExec :: OptCommonDb -> URI -> [SqlStmt] -> IO Connection Source #
pgsqlExecAndRollback :: OptCommonDb -> URI -> [SqlStmt] -> IO () Source #
:: OptCommonDb | |
-> Status | |
-> [SqlStmt] | Statements that still need to be executed |
-> [SqlStmt] | Statements that have failed during execution |
-> Connection | |
-> IO () |
pgsqlExecIntern :: OptCommonDb -> PgSqlMode -> URI -> [SqlStmt] -> IO Connection Source #
:: ToSqlId a | |
=> SqlStmtType | statment |
-> [a] | SQL ids that should become a SqlStmtId type to use |
-> [SqlStmtId] |
filterSqlStmtType :: SqlStmtType -> [SqlStmt] -> [SqlStmt] Source #
removeSqlIdBySqlStmts :: ToSqlId a => SqlStmtType -> [SqlStmt] -> [a] -> [a] Source #