@@ -184,7 +184,7 @@ createSchema sch = UnsafeDefinition $
184createSchemaIfNotExists
184createSchemaIfNotExists
185 :: (KnownSymbol sch, Has sch schemas schema)
185 :: (KnownSymbol sch, Has sch schemas schema)
186 => Alias sch
186 => Alias sch
187− -> Definition schemas schemas
187+ -> Definition schemas (CreateIfNotExists sch '[] schemas)
188createSchemaIfNotExists sch = UnsafeDefinition $
188createSchemaIfNotExists sch = UnsafeDefinition $
189 "CREATE" <+> "SCHEMA" <+> "IF" <+> "NOT" <+> "EXISTS"
189 "CREATE" <+> "SCHEMA" <+> "IF" <+> "NOT" <+> "EXISTS"
190 <+> renderSQL sch <> ";"
190 <+> renderSQL sch <> ";"
@@ -248,16 +248,19 @@ in printSQL setup
248CREATE TABLE IF NOT EXISTS "tab" ("a" int NULL, "b" real NULL);
248CREATE TABLE IF NOT EXISTS "tab" ("a" int NULL, "b" real NULL);
250createTableIfNotExists
250createTableIfNotExists
251− :: ( Has sch schemas schema
251+ :: ( KnownSymbol sch
252− , Has tab schema ('Table (constraints :=> columns))
252+ , KnownSymbol tab
253+ , columns ~ (col ': cols)
253 , SOP.SListI columns
254 , SOP.SListI columns
254− , SOP.SListI constraints )
255+ , SOP.SListI constraints
256+ , Has sch schemas0 schema0
257+ , schemas1 ~ Alter sch (CreateIfNotExists tab ('Table (constraints :=> columns)) schema0) schemas0 )
255 => QualifiedAlias sch tab -- ^ the name of the table to add
258 => QualifiedAlias sch tab -- ^ the name of the table to add
256− -> NP (Aliased (ColumnTypeExpression schemas)) columns
259+ -> NP (Aliased (ColumnTypeExpression schemas0)) columns
257 -- ^ the names and datatype of each column
260 -- ^ the names and datatype of each column
258− -> NP (Aliased (TableConstraintExpression sch tab schemas)) constraints
261+ -> NP (Aliased (TableConstraintExpression sch tab schemas1)) constraints
259 -- ^ constraints that must hold for the table
262 -- ^ constraints that must hold for the table
260− -> Definition schemas schemas
263+ -> Definition schemas0 schemas1
261createTableIfNotExists tab columns constraints = UnsafeDefinition $
264createTableIfNotExists tab columns constraints = UnsafeDefinition $
262 "CREATE TABLE IF NOT EXISTS"
265 "CREATE TABLE IF NOT EXISTS"
263 <+> renderCreation tab columns constraints
266 <+> renderCreation tab columns constraints