Commit 1567ee2b authored by Sophie Herold's avatar Sophie Herold 🌼

Adds basic support for domain inquires

parent a3a1a67d
Pipeline #818 passed with stage
in 3 minutes and 48 seconds
......@@ -30,6 +30,7 @@ deployedSchemas = do
toSchema (schema, description) = do
tables <- deployedTables schema
functions <- deployedFunctions schema
domains <- deployedDomains schema
return
Schema
{ schemaName = schema
......@@ -49,7 +50,7 @@ deployedSchemas = do
, schemaPrivSequenceAll = Nothing
, schemaPrivExecuteAll = Nothing
, schemaPrivAllAll = Nothing
, schemaDomains = Nothing
, schemaDomains = presetEmpty domains
, schemaTypes = Nothing
, schemaExecPostInstall = Nothing
, schemaExecPostInstallAndUpgrade = Nothing
......@@ -279,6 +280,32 @@ deployedFunctions schema = do
WHERE pronamespace::regnamespace = ?::regnamespace
|]
deployedDomains :: SqlName -> SqlT [Domain]
deployedDomains schema = do
doms <- psqlQry qry (Only $ toSqlCode schema)
return $ map toDomain doms
where
toDomain (domname, domdesc, domtype, domdefault) =
Domain
{ domainName = domname
, domainDescription = fromMaybe "" domdesc
, domainType = domtype
, domainDefault = domdefault
, domainChecks = Nothing -- Maybe [Check]
}
qry =
[sql|
SELECT
typname,
pg_catalog.obj_description(oid, 'pg_type')::text AS desc,
pg_catalog.format_type(typbasetype, typtypmod) AS domtype,
typdefault
FROM pg_type
WHERE
typtype = 'd'
AND typnamespace = ?::regnamespace::oid
|]
sqlManageSchemaJoin :: Text -> Text
sqlManageSchemaJoin schemaid =
" JOIN pg_namespace AS n " <\> " ON" <-> schemaid <-> "= n.oid AND " <\>
......
name: t_mydomain
description: My Domain
type: character varying(30)
name: t_mydomain2
description: My Domain
type: character varying
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment