@@ -590,8 +590,8 @@ newtype AlterTable
592-- definition :: Definition
592-- definition :: Definition
593−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]
593+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
594−-- '["tab" ::: 'Table ('["positive" ::: Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]
594+-- '["public" ::: '["tab" ::: 'Table ('["positive" ::: Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
595-- definition = alterTable #tab (addConstraint #positive (check #col (#col .> 0)))
595-- definition = alterTable #tab (addConstraint #positive (check #col (#col .> 0)))
596-- in printSQL definition
596-- in printSQL definition
@@ -615,8 +615,8 @@ addConstraint alias constraint = UnsafeAlterTable $
617-- definition :: Definition
617-- definition :: Definition
618−-- '["tab" ::: 'Table ('["positive" ::: Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]
618+-- '["public" ::: '["tab" ::: 'Table ('["positive" ::: Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
619−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]
619+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
620-- definition = alterTable #tab (dropConstraint #positive)
620-- definition = alterTable #tab (dropConstraint #positive)
621-- in printSQL definition
621-- in printSQL definition
@@ -641,10 +641,10 @@ class AddColumn ty where
641 -- >>> :{
641 -- >>> :{
643 -- definition :: Definition
643 -- definition :: Definition
644− -- '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]
644+ -- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]]
645− -- '["tab" ::: 'Table ('[] :=>
645+ -- '["public" ::: '["tab" ::: 'Table ('[] :=>
646 -- '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
646 -- '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
647− -- , "col2" ::: 'Def :=> 'Null 'PGtext ])]
647+ -- , "col2" ::: 'Def :=> 'Null 'PGtext ])]]
648 -- definition = alterTable #tab (addColumn #col2 (text & nullable & default_ "foo"))
648 -- definition = alterTable #tab (addColumn #col2 (text & nullable & default_ "foo"))
649 -- in printSQL definition
649 -- in printSQL definition
@@ -653,10 +653,10 @@ class AddColumn ty where
653 -- >>> :{
653 -- >>> :{
655 -- definition :: Definition
655 -- definition :: Definition
656− -- '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]
656+ -- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]]
657− -- '["tab" ::: 'Table ('[] :=>
657+ -- '["public" ::: '["tab" ::: 'Table ('[] :=>
658 -- '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
658 -- '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
659− -- , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]
659+ -- , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]]
660 -- definition = alterTable #tab (addColumn #col2 (text & nullable))
660 -- definition = alterTable #tab (addColumn #col2 (text & nullable))
661 -- in printSQL definition
661 -- in printSQL definition
@@ -682,10 +682,10 @@ instance {-# OVERLAPPABLE #-} AddColumn ('NoDef :=> 'Null ty)
684-- definition :: Definition
684-- definition :: Definition
685−-- '["tab" ::: 'Table ('[] :=>
685+-- '["public" ::: '["tab" ::: 'Table ('[] :=>
686-- '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
686-- '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
687−-- , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]
687+-- , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]]
688−-- '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]
688+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]]
689-- definition = alterTable #tab (dropColumn #col2)
689-- definition = alterTable #tab (dropColumn #col2)
690-- in printSQL definition
690-- in printSQL definition
@@ -706,8 +706,8 @@ dropColumn column = UnsafeAlterTable $
708-- definition :: Definition
708-- definition :: Definition
709−-- '["tab" ::: 'Table ('[] :=> '["foo" ::: 'NoDef :=> 'Null 'PGint4])]
709+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["foo" ::: 'NoDef :=> 'Null 'PGint4])]]
710−-- '["tab" ::: 'Table ('[] :=> '["bar" ::: 'NoDef :=> 'Null 'PGint4])]
710+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["bar" ::: 'NoDef :=> 'Null 'PGint4])]]
711-- definition = alterTable #tab (renameColumn #foo #bar)
711-- definition = alterTable #tab (renameColumn #foo #bar)
712-- in printSQL definition
712-- in printSQL definition
@@ -751,8 +751,8 @@ newtype AlterColumn (db :: DBType) (ty0 :: ColumnType) (ty1 :: ColumnType) =
753-- definition :: Definition
753-- definition :: Definition
754−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]
754+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
755−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'Def :=> 'Null 'PGint4])]
755+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'Def :=> 'Null 'PGint4])]]
756-- definition = alterTable #tab (alterColumn #col (setDefault 5))
756-- definition = alterTable #tab (alterColumn #col (setDefault 5))
757-- in printSQL definition
757-- in printSQL definition
@@ -768,8 +768,8 @@ setDefault expression = UnsafeAlterColumn $
770-- definition :: Definition
770-- definition :: Definition
771−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'Def :=> 'Null 'PGint4])]
771+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'Def :=> 'Null 'PGint4])]]
772−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]
772+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
773-- definition = alterTable #tab (alterColumn #col dropDefault)
773-- definition = alterTable #tab (alterColumn #col dropDefault)
774-- in printSQL definition
774-- in printSQL definition
@@ -784,8 +784,8 @@ dropDefault = UnsafeAlterColumn $ "DROP DEFAULT"
786-- definition :: Definition
786-- definition :: Definition
787−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]
787+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
788−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]
788+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
789-- definition = alterTable #tab (alterColumn #col setNotNull)
789-- definition = alterTable #tab (alterColumn #col setNotNull)
790-- in printSQL definition
790-- in printSQL definition
@@ -799,8 +799,8 @@ setNotNull = UnsafeAlterColumn $ "SET NOT NULL"
801-- definition :: Definition
801-- definition :: Definition
802−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]
802+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
803−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]
803+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
804-- definition = alterTable #tab (alterColumn #col dropNotNull)
804-- definition = alterTable #tab (alterColumn #col dropNotNull)
805-- in printSQL definition
805-- in printSQL definition
@@ -816,8 +816,8 @@ dropNotNull = UnsafeAlterColumn $ "DROP NOT NULL"
818-- definition :: Definition
818-- definition :: Definition
819−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]
819+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
820−-- '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGnumeric])]
820+-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGnumeric])]]
821-- definition =
821-- definition =
822-- alterTable #tab (alterColumn #col (alterType (numeric & notNullable)))
822-- alterTable #tab (alterColumn #col (alterType (numeric & notNullable)))
823-- in printSQL definition
823-- in printSQL definition
@@ -831,9 +831,9 @@ alterType ty = UnsafeAlterColumn $ "TYPE" <+> renderColumnTypeExpression ty
833-- definition :: Definition
833-- definition :: Definition
834−-- '[ "abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])]
834+-- '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])]]
835−-- '[ "abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])
835+-- '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])
836−-- , "bc" ::: 'View ('["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4])]
836+-- , "bc" ::: 'View ('["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4])]]
837-- definition =
837-- definition =
838-- createView #bc (select (#b :* #c) (from (table #abc)))
838-- createView #bc (select (#b :* #c) (from (table #abc)))
839-- in printSQL definition
839-- in printSQL definition
@@ -854,9 +854,9 @@ createView alias query = UnsafeDefinition $
856-- definition :: Definition
856-- definition :: Definition
857−-- '[ "abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])
857+-- '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])
858−-- , "bc" ::: 'View ('["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4])]
858+-- , "bc" ::: 'View ('["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4])]]
859−-- '[ "abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])]
859+-- '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])]]
860-- definition = dropView #bc
860-- definition = dropView #bc
861-- in printSQL definition
861-- in printSQL definition
@@ -869,7 +869,7 @@ dropView vw = UnsafeDefinition $ "DROP VIEW" <+> renderQualifiedAlias vw <> ";"
870-- | Enumerated types are created using the `createTypeEnum` command, for example
870-- | Enumerated types are created using the `createTypeEnum` command, for example
872−-- >>> printSQL $ createTypeEnum #mood (label @"sad" :* label @"ok" :* label @"happy")
872+-- >>> printSQL $ (createTypeEnum #mood (label @"sad" :* label @"ok" :* label @"happy") :: Definition '["public" ::: '[]] '["public" ::: '["mood" ::: 'Typedef ('PGenum '["sad","ok","happy"])]])
873-- CREATE TYPE "mood" AS ENUM ('sad', 'ok', 'happy');
873-- CREATE TYPE "mood" AS ENUM ('sad', 'ok', 'happy');
874createTypeEnum
874createTypeEnum
875 :: (KnownSymbol enum, Has sch db schema, SOP.All KnownSymbol labels)
875 :: (KnownSymbol enum, Has sch db schema, SOP.All KnownSymbol labels)
@@ -887,7 +887,13 @@ createTypeEnum enum labels = UnsafeDefinition $
887-- >>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
887-- >>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
888-- >>> instance SOP.Generic Schwarma
888-- >>> instance SOP.Generic Schwarma
889-- >>> instance SOP.HasDatatypeInfo Schwarma
889-- >>> instance SOP.HasDatatypeInfo Schwarma
892+-- createSchwarma :: Definition '["public" ::: '[]] '["public" ::: '["schwarma" ::: 'Typedef (PG (Enumerated Schwarma))]]
890−-- >>> printSQL $ createTypeEnumFrom @Schwarma #schwarma
893+-- createSchwarma = createTypeEnumFrom @Schwarma #schwarma
895+-- printSQL createSchwarma
891-- CREATE TYPE "schwarma" AS ENUM ('Beef', 'Lamb', 'Chicken');
897-- CREATE TYPE "schwarma" AS ENUM ('Beef', 'Lamb', 'Chicken');
892createTypeEnumFrom
898createTypeEnumFrom
893 :: forall hask sch enum db schema.
899 :: forall hask sch enum db schema.
@@ -912,7 +918,7 @@ type PGcomplex = 'PGcomposite
915− setup :: Definition '[] '["complex" ::: 'Typedef PGcomplex]
921+ setup :: Definition '["public" ::: '[]] '["public" ::: '["complex" ::: 'Typedef PGcomplex]]
916 setup = createTypeComposite #complex
922 setup = createTypeComposite #complex
917 (float8 `as` #real :* float8 `as` #imaginary)
923 (float8 `as` #real :* float8 `as` #imaginary)
918in printSQL setup
924in printSQL setup
@@ -939,7 +945,14 @@ createTypeComposite ty fields = UnsafeDefinition $
939-- >>> data Complex = Complex {real :: Double, imaginary :: Double} deriving GHC.Generic
945-- >>> data Complex = Complex {real :: Double, imaginary :: Double} deriving GHC.Generic
940-- >>> instance SOP.Generic Complex
946-- >>> instance SOP.Generic Complex
941-- >>> instance SOP.HasDatatypeInfo Complex
947-- >>> instance SOP.HasDatatypeInfo Complex
948+-- >>> type DB = '["public" ::: '["complex" ::: 'Typedef (PG (Composite Complex))]]
951+-- createComplex :: Definition '["public" ::: '[]] DB
942−-- >>> printSQL $ createTypeCompositeFrom @Complex #complex
952+-- createComplex = createTypeCompositeFrom @Complex #complex
954+-- printSQL createComplex
943-- CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);
956-- CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);
944createTypeCompositeFrom
957createTypeCompositeFrom
945 :: forall hask sch ty db schema.
958 :: forall hask sch ty db schema.
@@ -964,7 +977,7 @@ instance (KnownSymbol alias, PGTyped db ty)
964-- >>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
977-- >>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
965-- >>> instance SOP.Generic Schwarma
978-- >>> instance SOP.Generic Schwarma
966-- >>> instance SOP.HasDatatypeInfo Schwarma
979-- >>> instance SOP.HasDatatypeInfo Schwarma
967−-- >>> printSQL (dropType #schwarma :: Definition '["schwarma" ::: 'Typedef (PG (Enumerated Schwarma))] '[])
980+-- >>> printSQL (dropType #schwarma :: Definition '["public" ::: '["schwarma" ::: 'Typedef (PG (Enumerated Schwarma))]] '["public" ::: '[]])
968-- DROP TYPE "schwarma";
981-- DROP TYPE "schwarma";
970 :: (Has sch db schema, Has td schema ('Typedef ty))
983 :: (Has sch db schema, Has td schema ('Typedef ty))