mirror of
https://github.com/ilyakooo0/squeal.git
synced 2024-09-11 13:57:29 +03:00
ddl fams
This commit is contained in:
parent
787bbc412e
commit
9282502a7a
@ -70,11 +70,13 @@ module Squeal.PostgreSQL.Definition
|
||||
, languageSqlQuery
|
||||
-- ** Drop
|
||||
, dropSchema
|
||||
, dropSchemaIfExists
|
||||
, dropTable
|
||||
, dropTableIfExists
|
||||
, dropView
|
||||
, dropType
|
||||
, dropIndex
|
||||
, dropIndexIfExists
|
||||
, dropFunction
|
||||
, dropOperator
|
||||
-- ** Alter
|
||||
@ -596,6 +598,14 @@ dropSchema
|
||||
-> Definition schemas (Drop sch schemas)
|
||||
dropSchema sch = UnsafeDefinition $ "DROP SCHEMA" <+> renderSQL sch <> ";"
|
||||
|
||||
dropSchemaIfExists
|
||||
:: Has sch schemas schema
|
||||
=> Alias sch
|
||||
-- ^ user defined schema
|
||||
-> Definition schemas (Drop sch schemas)
|
||||
dropSchemaIfExists sch = UnsafeDefinition $
|
||||
"DROP SCHEMA IF EXISTS" <+> renderSQL sch <> ";"
|
||||
|
||||
-- | `dropTable` removes a table from the schema.
|
||||
--
|
||||
-- >>> :{
|
||||
@ -952,6 +962,13 @@ dropView
|
||||
-> Definition schemas (Alter sch (Drop vw schema) schemas)
|
||||
dropView vw = UnsafeDefinition $ "DROP VIEW" <+> renderSQL vw <> ";"
|
||||
|
||||
dropViewIfExists
|
||||
:: (Has sch schemas schema, Has vw schema ('View view))
|
||||
=> QualifiedAlias sch vw -- ^ view to remove
|
||||
-> Definition schemas (Alter sch (Drop vw schema) schemas)
|
||||
dropViewIfExists vw = UnsafeDefinition $
|
||||
"DROP VIEW IF EXISTS" <+> renderSQL vw <> ";"
|
||||
|
||||
-- | Enumerated types are created using the `createTypeEnum` command, for example
|
||||
--
|
||||
-- >>> printSQL $ (createTypeEnum #mood (label @"sad" :* label @"ok" :* label @"happy") :: Definition (Public '[]) '["public" ::: '["mood" ::: 'Typedef ('PGenum '["sad","ok","happy"])]])
|
||||
@ -1325,6 +1342,14 @@ dropIndex
|
||||
-> Definition schemas (Alter sch (Drop ix schema) schemas)
|
||||
dropIndex ix = UnsafeDefinition $ "DROP" <+> "INDEX" <+> renderSQL ix <> ";"
|
||||
|
||||
dropIndexIfExists
|
||||
:: (Has sch schemas schema, Has ix schema 'Index)
|
||||
=> QualifiedAlias sch ix
|
||||
-- ^ name of the user defined index
|
||||
-> Definition schemas (Alter sch (DropIfExists ix schema) schemas)
|
||||
dropIndexIfExists ix = UnsafeDefinition $
|
||||
"DROP INDEX IF EXISTS" <+> renderSQL ix <> ";"
|
||||
|
||||
-- | Lift `PGTyped` to a field
|
||||
class FieldTyped schemas ty where
|
||||
fieldtype :: Aliased (TypeExpression schemas) ty
|
||||
|
@ -325,7 +325,7 @@ type family Create alias x xs where
|
||||
Create alias x (alias ::: y ': xs) = TypeError
|
||||
('Text "Create: alias "
|
||||
':<>: 'ShowType alias
|
||||
':<>: 'Text "already in use")
|
||||
':<>: 'Text "already exists")
|
||||
Create alias y (x ': xs) = x ': Create alias y xs
|
||||
|
||||
type family CreateOrReplace alias x xs where
|
||||
|
Loading…
Reference in New Issue
Block a user