on dev help sign in
Merge pull request #98 from morphismtech/dev-drop-schema
5481afaEitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+22−9
@@ -37,6 +37,11 @@ module Squeal.PostgreSQL.Definition
37 , createSchemaIfNotExists
37 , createSchemaIfNotExists
38 , createTable
38 , createTable
39 , createTableIfNotExists
39 , createTableIfNotExists
40+ , createView
41+ , createTypeEnum
42+ , createTypeEnumFrom
43+ , createTypeComposite
44+ , createTypeCompositeFrom
40 , TableConstraintExpression (..)
45 , TableConstraintExpression (..)
41 , check
46 , check
42 , unique
47 , unique
@@ -46,7 +51,10 @@ module Squeal.PostgreSQL.Definition
46 , OnDeleteClause (..)
51 , OnDeleteClause (..)
47 , OnUpdateClause (..)
52 , OnUpdateClause (..)
48 -- ** Drop
53 -- ** Drop
54+ , dropSchema
49 , dropTable
55 , dropTable
56+ , dropView
57+ , dropType
50 -- ** Alter
58 -- ** Alter
51 , alterTable
59 , alterTable
52 , alterTableRename
60 , alterTableRename
@@ -63,15 +71,6 @@ module Squeal.PostgreSQL.Definition
63 , setNotNull
71 , setNotNull
64 , dropNotNull
72 , dropNotNull
65 , alterType
73 , alterType
66− -- * Views
67− , createView
68− , dropView
69− -- * Types
70− , createTypeEnum
71− , createTypeEnumFrom
72− , createTypeComposite
73− , createTypeCompositeFrom
74− , dropType
75 -- * Columns
74 -- * Columns
76 , ColumnTypeExpression (..)
75 , ColumnTypeExpression (..)
77 , nullable
76 , nullable
@@ -530,6 +529,20 @@ instance RenderSQL OnUpdateClause where
530DROP statements
529DROP statements
531-----------------------------------------}
530-----------------------------------------}
532
531
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+
533-- | `dropTable` removes a table from the schema.
546-- | `dropTable` removes a table from the schema.
534--
547--
535-- >>> :{
548-- >>> :{