on dev help sign in
Merge pull request #98 from morphismtech/dev-drop-schema

Dev drop schema

commit5481afa1bc1e8445f558be8359b2cf47a53328e3 authorEitan Chatav <eitan.chatav@gmail.com> dateFri 15 Feb 2019, 23:59 (8 years ago) parent7caa3a2ec6ffec
1 file changed+22−9
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+22−9
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+22−9
@@ -37,6 +37,11 @@ module Squeal.PostgreSQL.Definition
3737 , createSchemaIfNotExists
3838 , createTable
3939 , createTableIfNotExists
40+ , createView
41+ , createTypeEnum
42+ , createTypeEnumFrom
43+ , createTypeComposite
44+ , createTypeCompositeFrom
4045 , TableConstraintExpression (..)
4146 , check
4247 , unique
@@ -46,7 +51,10 @@ module Squeal.PostgreSQL.Definition
4651 , OnDeleteClause (..)
4752 , OnUpdateClause (..)
4853 -- ** Drop
54+ , dropSchema
4955 , dropTable
56+ , dropView
57+ , dropType
5058 -- ** Alter
5159 , alterTable
5260 , alterTableRename
@@ -63,15 +71,6 @@ module Squeal.PostgreSQL.Definition
6371 , setNotNull
6472 , dropNotNull
6573 , alterType
66− -- * Views
67− , createView
68− , dropView
69− -- * Types
70− , createTypeEnum
71− , createTypeEnumFrom
72− , createTypeComposite
73− , createTypeCompositeFrom
74− , dropType
7574 -- * Columns
7675 , ColumnTypeExpression (..)
7776 , nullable
@@ -530,6 +529,20 @@ instance RenderSQL OnUpdateClause where
530529DROP statements
531530-----------------------------------------}
532531
532+-- >>> :{
533+-- let
534+-- definition :: Definition '["muh_schema" ::: schema, "public" ::: public] '["public" ::: public]
535+-- definition = dropSchema #muh_schema
536+-- :}
537+--
538+-- >>> printSQL definition
539+-- DROP SCHEMA "muh_schema";
540+dropSchema
541+ :: Has sch schemas schema
542+ => Alias sch
543+ -> Definition schemas (Drop sch schemas)
544+dropSchema sch = UnsafeDefinition $ "DROP SCHEMA" <+> renderSQL sch <> ";"
545+
533546-- | `dropTable` removes a table from the schema.
534547--
535548-- >>> :{