Copyright | (c) Eitan Chatav 2019 |
---|---|
Maintainer | eitan@morphism.tech |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
create and drop schemas
Synopsis
- createSchema :: KnownSymbol sch => Alias sch -> Definition db (Create sch '[] db)
- createSchemaIfNotExists :: (KnownSymbol sch, Has sch db schema) => Alias sch -> Definition db (CreateIfNotExists sch '[] db)
- dropSchemaCascade :: KnownSymbol sch => Alias sch -> Definition db (Drop sch db)
- dropSchemaCascadeIfExists :: KnownSymbol sch => Alias sch -> Definition db (DropIfExists sch db)
Create
:: KnownSymbol sch | |
=> Alias sch | schema alias |
-> Definition db (Create sch '[] db) |
createSchema
enters a new schema into the current database.
The schema name must be distinct from the name of any existing schema
in the current database.
A schema is essentially a namespace: it contains named objects
(tables, data types, functions, and operators) whose names
can duplicate those of other objects existing in other schemas.
Named objects are accessed by QualifiedAlias
es with the schema
name as a prefix.
>>>
:{
let definition :: Definition '["public" ::: '[]] '["public" ::: '[], "my_schema" ::: '[]] definition = createSchema #my_schema in printSQL definition :} CREATE SCHEMA "my_schema";
createSchemaIfNotExists Source #
:: (KnownSymbol sch, Has sch db schema) | |
=> Alias sch | schema alias |
-> Definition db (CreateIfNotExists sch '[] db) |
Create a schema if it does not yet exist.
Drop
:: KnownSymbol sch | |
=> Alias sch | schema alias |
-> Definition db (Drop sch db) |
Drop a schema. Automatically drop objects (tables, functions, etc.) that are contained in the schema.
>>>
:{
let definition :: Definition '["muh_schema" ::: schema, "public" ::: public] '["public" ::: public] definition = dropSchemaCascade #muh_schema :}
>>>
printSQL definition
DROP SCHEMA "muh_schema" CASCADE;
dropSchemaCascadeIfExists Source #
:: KnownSymbol sch | |
=> Alias sch | schema alias |
-> Definition db (DropIfExists sch db) |
Drop a schema if it exists. Automatically drop objects (tables, functions, etc.) that are contained in the schema.