squeal-postgresql-0.9.0.0: Squeal PostgreSQL Library
Copyright(c) Eitan Chatav 2019
Maintainereitan@morphism.tech
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Squeal.PostgreSQL.Definition.Schema

Contents

Description

create and drop schemas

Synopsis

Create

createSchema Source #

Arguments

:: 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 QualifiedAliases 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 #

Arguments

:: (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

dropSchemaCascade Source #

Arguments

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

Arguments

:: 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.