pg-schema
Copyright(c) Dmitry Olshansky
LicenseBSD-3-Clause
Maintainerolshanskydr@gmail.com, dima@typeable.io
Stabilityexperimental
Safe HaskellNone
LanguageGHC2021

PgSchema.Generation

Description

Generation of type-level database schema definitions

Typically you build an executable that imports this module and run it to emit the schema definition.

Synopsis

Documentation

updateSchemaFile Source #

Arguments

:: Bool

verbose mode

-> String

file name

-> Either String ByteString

name of environment variable with connection string, or the connection string itself. When this environment variable is not set or the connection string is empty, we do nothing.

-> Text

haskell module name to generate

-> Text

name of generated haskell type for schema

-> GenNames

names of schemas in database or tables to generate

-> IO Bool 

Update (or create) the Haskell file containing the schema definition

data GenNames Source #

Constructors

GenNames 

Fields

data AddRelation Source #

Constructors

AddRelation 

Fields

  • name :: Text

    name of an additional (non-existing in the database) relation. All additional relations will be added with the namespace "_add".

  • from :: NameNS
     
  • to :: NameNS
     
  • cols :: [(Text, Text)]
     

data NameNS' s Source #

Qualified PostgreSQL name: namespace (schema) + local name.

Constructors

NameNS 

Fields

  • nnsNamespace :: s

    Namespace (database schema), e.g. public or pg_catalog.

  • nnsName :: s

    Unqualified table relation type name.

Instances

Instances details
SingI2 ('NameNS :: k2 -> k2 -> NameNS' k2) Source # 
Instance details

Defined in PgSchema.Schema

Methods

liftSing2 :: forall (x :: k2) (y :: k2). Sing x -> Sing y -> Sing ('NameNS x y) #

SingI n => SingI1 ('NameNS n :: s -> NameNS' s) Source # 
Instance details

Defined in PgSchema.Schema

Methods

liftSing :: forall (x :: s). Sing x -> Sing ('NameNS n x) #

Show s => Show (NameNS' s) Source # 
Instance details

Defined in PgSchema.Schema

Methods

showsPrec :: Int -> NameNS' s -> ShowS #

show :: NameNS' s -> String #

showList :: [NameNS' s] -> ShowS #

Eq s => Eq (NameNS' s) Source # 
Instance details

Defined in PgSchema.Schema

Methods

(==) :: NameNS' s -> NameNS' s -> Bool #

(/=) :: NameNS' s -> NameNS' s -> Bool #

Ord s => Ord (NameNS' s) Source # 
Instance details

Defined in PgSchema.Schema

Methods

compare :: NameNS' s -> NameNS' s -> Ordering #

(<) :: NameNS' s -> NameNS' s -> Bool #

(<=) :: NameNS' s -> NameNS' s -> Bool #

(>) :: NameNS' s -> NameNS' s -> Bool #

(>=) :: NameNS' s -> NameNS' s -> Bool #

max :: NameNS' s -> NameNS' s -> NameNS' s #

min :: NameNS' s -> NameNS' s -> NameNS' s #

SingKind s => SingKind (NameNS' s) Source # 
Instance details

Defined in PgSchema.Schema

Associated Types

type Demote (NameNS' s) 
Instance details

Defined in PgSchema.Schema

type Demote (NameNS' s) = NameNS' (Demote s)

Methods

fromSing :: forall (a :: NameNS' s). Sing a -> Demote (NameNS' s) #

toSing :: Demote (NameNS' s) -> SomeSing (NameNS' s) #

SingI n => SingI2 ('RelDef n :: NameNS' s -> [(s, s)] -> RelDef' s) Source # 
Instance details

Defined in PgSchema.Schema

Methods

liftSing2 :: forall (x :: NameNS' s) (y :: [(s, s)]). Sing x -> Sing y -> Sing ('RelDef n x y) #

SingI n => SingI2 ('TypDef n :: Maybe (NameNS' s) -> [s] -> TypDef' s) Source # 
Instance details

Defined in PgSchema.Schema

Methods

liftSing2 :: forall (x :: Maybe (NameNS' s)) (y :: [s]). Sing x -> Sing y -> Sing ('TypDef n x y) #

(SingI n1, SingI n2) => SingI ('NameNS n1 n2 :: NameNS' s) Source # 
Instance details

Defined in PgSchema.Schema

Methods

sing :: Sing ('NameNS n1 n2) #

FromJSON a => FromJSON (PgTag s (PgArr a)) Source # 
Instance details

Defined in PgSchema.Types

ToJSON a => ToJSON (PgTag s (PgArr a)) Source # 
Instance details

Defined in PgSchema.Types

Methods

toJSON :: PgTag s (PgArr a) -> Value #

toEncoding :: PgTag s (PgArr a) -> Encoding #

toJSONList :: [PgTag s (PgArr a)] -> Value #

toEncodingList :: [PgTag s (PgArr a)] -> Encoding #

omitField :: PgTag s (PgArr a) -> Bool #

(ToField a, ToStar s) => ToField (PgTag s (PgArr a)) Source # 
Instance details

Defined in PgSchema.Types

Methods

toField :: PgTag s (PgArr a) -> Action #

type CanConvert1 sch tab fld tn ('TypDef "A" ('Just n) y) (PgArr t) Source # 
Instance details

Defined in PgSchema.Types

type CanConvert1 sch tab fld tn ('TypDef "A" ('Just n) y) (PgArr t) = CanConvert1 sch tab fld n (TTypDef sch n) t
type CanConvert1 sch tab fld n ('TypDef "E" ('Nothing :: Maybe (NameNS' Symbol)) es) (PGEnum sch n) Source # 
Instance details

Defined in PgSchema.Types

type CanConvert1 sch tab fld n ('TypDef "E" ('Nothing :: Maybe (NameNS' Symbol)) es) (PGEnum sch n)
type CanConvert1 sch tab fld (PGC "citext") ('TypDef "S" ('Nothing :: Maybe (NameNS' Symbol)) ('[] :: [Symbol])) (CI Text) Source # 
Instance details

Defined in PgSchema.Types

type CanConvert1 sch tab fld (PGC "citext") ('TypDef "S" ('Nothing :: Maybe (NameNS' Symbol)) ('[] :: [Symbol])) (CI Text) = ()
type CanConvert1 sch tab fld ("public" ->> "citext") ('TypDef "S" ('Nothing :: Maybe (NameNS' Symbol)) ('[] :: [Symbol])) (CI Text) Source # 
Instance details

Defined in PgSchema.Types

type CanConvert1 sch tab fld ("public" ->> "citext") ('TypDef "S" ('Nothing :: Maybe (NameNS' Symbol)) ('[] :: [Symbol])) (CI Text) = ()
type Demote (NameNS' s) Source # 
Instance details

Defined in PgSchema.Schema

type Demote (NameNS' s) = NameNS' (Demote s)
type Sing Source # 
Instance details

Defined in PgSchema.Schema

type Sing

(->>) :: Text -> Text -> NameNS infixr 9 Source #