{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
module Hasura.RQL.DDL.Schema.LegacyCatalog
( saveMetadataToHdbTables,
fetchMetadataFromHdbTables,
recreateSystemMetadata,
addCronTriggerForeignKeyConstraint,
parseLegacyRemoteRelationshipDefinition,
)
where
import Control.Lens hiding ((.=))
import Data.Aeson
import Data.FileEmbed (makeRelativeToProject)
import Data.HashMap.Strict qualified as HashMap
import Data.HashMap.Strict.InsOrd qualified as InsOrdHashMap
import Data.Text.Extended ((<<>))
import Data.Text.NonEmpty
import Data.Time.Clock qualified as C
import Database.PG.Query qualified as PG
import Hasura.Backends.Postgres.Connection
import Hasura.Backends.Postgres.SQL.Types as Postgres
import Hasura.Base.Error
import Hasura.Eventing.ScheduledTrigger
import Hasura.Function.Cache
import Hasura.Function.Metadata (FunctionMetadata (..))
import Hasura.Prelude
import Hasura.RQL.DDL.Action
import Hasura.RQL.DDL.ComputedField
import Hasura.RQL.DDL.Permission
import Hasura.RQL.DDL.RemoteRelationship
import Hasura.RQL.Types.Action
import Hasura.RQL.Types.Allowlist
import Hasura.RQL.Types.Backend
import Hasura.RQL.Types.BackendType
import Hasura.RQL.Types.Common
import Hasura.RQL.Types.CustomTypes
import Hasura.RQL.Types.EventTrigger
import Hasura.RQL.Types.Metadata
import Hasura.RQL.Types.Permission
import Hasura.RQL.Types.QueryCollection
import Hasura.RQL.Types.Relationships.Local
import Hasura.RQL.Types.Relationships.Remote
import Hasura.RQL.Types.ScheduledTrigger
import Hasura.RQL.Types.SchemaCache
import Hasura.RemoteSchema.Metadata
import Hasura.Table.Metadata
( TableMetadata (..),
mkTableMeta,
tmArrayRelationships,
tmComputedFields,
tmDeletePermissions,
tmEventTriggers,
tmInsertPermissions,
tmObjectRelationships,
tmRemoteRelationships,
tmSelectPermissions,
tmUpdatePermissions,
)
saveMetadataToHdbTables ::
(MonadTx m, MonadReader SystemDefined m) => MetadataNoSources -> m ()
saveMetadataToHdbTables :: forall (m :: * -> *).
(MonadTx m, MonadReader SystemDefined m) =>
MetadataNoSources -> m ()
saveMetadataToHdbTables
( MetadataNoSources
Tables ('Postgres 'Vanilla)
tables
Functions ('Postgres 'Vanilla)
functions
RemoteSchemas
schemas
QueryCollections
collections
MetadataAllowlist
allowlist
CustomTypes
customTypes
Actions
actions
CronTriggers
cronTriggers
) = do
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"tables" (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ do
InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla))
-> (TableMetadata ('Postgres 'Vanilla) -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ Tables ('Postgres 'Vanilla)
InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla))
tables ((TableMetadata ('Postgres 'Vanilla) -> m ()) -> m ())
-> (TableMetadata ('Postgres 'Vanilla) -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \TableMetadata {Bool
Maybe ApolloFederationConfig
Maybe LogicalModelName
Permissions (UpdPermDef ('Postgres 'Vanilla))
Permissions (DelPermDef ('Postgres 'Vanilla))
Permissions (SelPermDef ('Postgres 'Vanilla))
Permissions (InsPermDef ('Postgres 'Vanilla))
RemoteRelationships
Relationships (ObjRelDef ('Postgres 'Vanilla))
Relationships (ArrRelDef ('Postgres 'Vanilla))
ComputedFields ('Postgres 'Vanilla)
EventTriggers ('Postgres 'Vanilla)
TableName ('Postgres 'Vanilla)
TableConfig ('Postgres 'Vanilla)
_tmTable :: TableName ('Postgres 'Vanilla)
_tmIsEnum :: Bool
_tmConfiguration :: TableConfig ('Postgres 'Vanilla)
_tmObjectRelationships :: Relationships (ObjRelDef ('Postgres 'Vanilla))
_tmArrayRelationships :: Relationships (ArrRelDef ('Postgres 'Vanilla))
_tmComputedFields :: ComputedFields ('Postgres 'Vanilla)
_tmRemoteRelationships :: RemoteRelationships
_tmInsertPermissions :: Permissions (InsPermDef ('Postgres 'Vanilla))
_tmSelectPermissions :: Permissions (SelPermDef ('Postgres 'Vanilla))
_tmUpdatePermissions :: Permissions (UpdPermDef ('Postgres 'Vanilla))
_tmDeletePermissions :: Permissions (DelPermDef ('Postgres 'Vanilla))
_tmEventTriggers :: EventTriggers ('Postgres 'Vanilla)
_tmApolloFederationConfig :: Maybe ApolloFederationConfig
_tmLogicalModel :: Maybe LogicalModelName
_tmTable :: forall (b :: BackendType). TableMetadata b -> TableName b
_tmIsEnum :: forall (b :: BackendType). TableMetadata b -> Bool
_tmConfiguration :: forall (b :: BackendType). TableMetadata b -> TableConfig b
_tmObjectRelationships :: forall (b :: BackendType).
TableMetadata b -> Relationships (ObjRelDef b)
_tmArrayRelationships :: forall (b :: BackendType).
TableMetadata b -> Relationships (ArrRelDef b)
_tmComputedFields :: forall (b :: BackendType). TableMetadata b -> ComputedFields b
_tmRemoteRelationships :: forall (b :: BackendType). TableMetadata b -> RemoteRelationships
_tmInsertPermissions :: forall (b :: BackendType).
TableMetadata b -> Permissions (InsPermDef b)
_tmSelectPermissions :: forall (b :: BackendType).
TableMetadata b -> Permissions (SelPermDef b)
_tmUpdatePermissions :: forall (b :: BackendType).
TableMetadata b -> Permissions (UpdPermDef b)
_tmDeletePermissions :: forall (b :: BackendType).
TableMetadata b -> Permissions (DelPermDef b)
_tmEventTriggers :: forall (b :: BackendType). TableMetadata b -> EventTriggers b
_tmApolloFederationConfig :: forall (b :: BackendType).
TableMetadata b -> Maybe ApolloFederationConfig
_tmLogicalModel :: forall (b :: BackendType).
TableMetadata b -> Maybe LogicalModelName
..} -> do
QualifiedTable -> Bool -> TableConfig ('Postgres 'Vanilla) -> m ()
forall (m :: * -> *).
(MonadTx m, MonadReader SystemDefined m) =>
QualifiedTable -> Bool -> TableConfig ('Postgres 'Vanilla) -> m ()
saveTableToCatalog TableName ('Postgres 'Vanilla)
QualifiedTable
_tmTable Bool
_tmIsEnum TableConfig ('Postgres 'Vanilla)
_tmConfiguration
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"object_relationships"
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ Relationships (ObjRelDef ('Postgres 'Vanilla))
-> (ObjRelDef ('Postgres 'Vanilla) -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ Relationships (ObjRelDef ('Postgres 'Vanilla))
_tmObjectRelationships
((ObjRelDef ('Postgres 'Vanilla) -> m ()) -> m ())
-> (ObjRelDef ('Postgres 'Vanilla) -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \ObjRelDef ('Postgres 'Vanilla)
objRel ->
QualifiedTable -> RelType -> ObjRelDef ('Postgres 'Vanilla) -> m ()
forall (m :: * -> *) a.
(MonadTx m, MonadReader SystemDefined m, ToJSON a) =>
QualifiedTable -> RelType -> RelDef a -> m ()
insertRelationshipToCatalog TableName ('Postgres 'Vanilla)
QualifiedTable
_tmTable RelType
ObjRel ObjRelDef ('Postgres 'Vanilla)
objRel
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"array_relationships"
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ Relationships (ArrRelDef ('Postgres 'Vanilla))
-> (ArrRelDef ('Postgres 'Vanilla) -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ Relationships (ArrRelDef ('Postgres 'Vanilla))
_tmArrayRelationships
((ArrRelDef ('Postgres 'Vanilla) -> m ()) -> m ())
-> (ArrRelDef ('Postgres 'Vanilla) -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \ArrRelDef ('Postgres 'Vanilla)
arrRel ->
QualifiedTable -> RelType -> ArrRelDef ('Postgres 'Vanilla) -> m ()
forall (m :: * -> *) a.
(MonadTx m, MonadReader SystemDefined m, ToJSON a) =>
QualifiedTable -> RelType -> RelDef a -> m ()
insertRelationshipToCatalog TableName ('Postgres 'Vanilla)
QualifiedTable
_tmTable RelType
ArrRel ArrRelDef ('Postgres 'Vanilla)
arrRel
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"computed_fields"
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ ComputedFields ('Postgres 'Vanilla)
-> (ComputedFieldMetadata ('Postgres 'Vanilla) -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ ComputedFields ('Postgres 'Vanilla)
_tmComputedFields
((ComputedFieldMetadata ('Postgres 'Vanilla) -> m ()) -> m ())
-> (ComputedFieldMetadata ('Postgres 'Vanilla) -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \(ComputedFieldMetadata ComputedFieldName
name ComputedFieldDefinition ('Postgres 'Vanilla)
definition Comment
comment) ->
AddComputedField ('Postgres 'Vanilla) -> m ()
forall (m :: * -> *).
MonadTx m =>
AddComputedField ('Postgres 'Vanilla) -> m ()
addComputedFieldToCatalog
(AddComputedField ('Postgres 'Vanilla) -> m ())
-> AddComputedField ('Postgres 'Vanilla) -> m ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> TableName ('Postgres 'Vanilla)
-> ComputedFieldName
-> ComputedFieldDefinition ('Postgres 'Vanilla)
-> Comment
-> AddComputedField ('Postgres 'Vanilla)
forall (b :: BackendType).
SourceName
-> TableName b
-> ComputedFieldName
-> ComputedFieldDefinition b
-> Comment
-> AddComputedField b
AddComputedField SourceName
defaultSource TableName ('Postgres 'Vanilla)
_tmTable ComputedFieldName
name ComputedFieldDefinition ('Postgres 'Vanilla)
definition Comment
comment
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"remote_relationships"
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ RemoteRelationships -> (RemoteRelationship -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ RemoteRelationships
_tmRemoteRelationships
((RemoteRelationship -> m ()) -> m ())
-> (RemoteRelationship -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \RemoteRelationship {RelName
RemoteRelationshipDefinition
_rrName :: RelName
_rrDefinition :: RemoteRelationshipDefinition
_rrName :: forall definition. RemoteRelationshipG definition -> RelName
_rrDefinition :: forall definition. RemoteRelationshipG definition -> definition
..} -> do
CreateFromSourceRelationship ('Postgres 'Vanilla) -> m ()
forall (m :: * -> *).
MonadTx m =>
CreateFromSourceRelationship ('Postgres 'Vanilla) -> m ()
addRemoteRelationshipToCatalog
(CreateFromSourceRelationship ('Postgres 'Vanilla) -> m ())
-> CreateFromSourceRelationship ('Postgres 'Vanilla) -> m ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> TableName ('Postgres 'Vanilla)
-> RelName
-> RemoteRelationshipDefinition
-> CreateFromSourceRelationship ('Postgres 'Vanilla)
forall (b :: BackendType).
SourceName
-> TableName b
-> RelName
-> RemoteRelationshipDefinition
-> CreateFromSourceRelationship b
CreateFromSourceRelationship SourceName
defaultSource TableName ('Postgres 'Vanilla)
_tmTable RelName
_rrName RemoteRelationshipDefinition
_rrDefinition
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"insert_permissions" (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ QualifiedTable
-> Permissions (InsPermDef ('Postgres 'Vanilla)) -> m ()
forall {m :: * -> *} {b :: BackendType} {t :: * -> *}
{a :: BackendType -> *}.
(MonadReader SystemDefined m, MonadTx m, Backend b, Foldable t) =>
QualifiedTable -> t (PermDef b a) -> m ()
processPerms TableName ('Postgres 'Vanilla)
QualifiedTable
_tmTable Permissions (InsPermDef ('Postgres 'Vanilla))
_tmInsertPermissions
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"select_permissions" (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ QualifiedTable
-> Permissions (SelPermDef ('Postgres 'Vanilla)) -> m ()
forall {m :: * -> *} {b :: BackendType} {t :: * -> *}
{a :: BackendType -> *}.
(MonadReader SystemDefined m, MonadTx m, Backend b, Foldable t) =>
QualifiedTable -> t (PermDef b a) -> m ()
processPerms TableName ('Postgres 'Vanilla)
QualifiedTable
_tmTable Permissions (SelPermDef ('Postgres 'Vanilla))
_tmSelectPermissions
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"update_permissions" (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ QualifiedTable
-> Permissions (UpdPermDef ('Postgres 'Vanilla)) -> m ()
forall {m :: * -> *} {b :: BackendType} {t :: * -> *}
{a :: BackendType -> *}.
(MonadReader SystemDefined m, MonadTx m, Backend b, Foldable t) =>
QualifiedTable -> t (PermDef b a) -> m ()
processPerms TableName ('Postgres 'Vanilla)
QualifiedTable
_tmTable Permissions (UpdPermDef ('Postgres 'Vanilla))
_tmUpdatePermissions
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"delete_permissions" (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ QualifiedTable
-> Permissions (DelPermDef ('Postgres 'Vanilla)) -> m ()
forall {m :: * -> *} {b :: BackendType} {t :: * -> *}
{a :: BackendType -> *}.
(MonadReader SystemDefined m, MonadTx m, Backend b, Foldable t) =>
QualifiedTable -> t (PermDef b a) -> m ()
processPerms TableName ('Postgres 'Vanilla)
QualifiedTable
_tmTable Permissions (DelPermDef ('Postgres 'Vanilla))
_tmDeletePermissions
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"event_triggers"
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ EventTriggers ('Postgres 'Vanilla)
-> (EventTriggerConf ('Postgres 'Vanilla) -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ EventTriggers ('Postgres 'Vanilla)
_tmEventTriggers
((EventTriggerConf ('Postgres 'Vanilla) -> m ()) -> m ())
-> (EventTriggerConf ('Postgres 'Vanilla) -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \EventTriggerConf ('Postgres 'Vanilla)
etc -> QualifiedTable -> EventTriggerConf ('Postgres 'Vanilla) -> m ()
forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadTx m, Backend ('Postgres pgKind)) =>
QualifiedTable -> EventTriggerConf ('Postgres pgKind) -> m ()
addEventTriggerToCatalog TableName ('Postgres 'Vanilla)
QualifiedTable
_tmTable EventTriggerConf ('Postgres 'Vanilla)
etc
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"functions"
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ InsOrdHashMap
QualifiedFunction (FunctionMetadata ('Postgres 'Vanilla))
-> (FunctionMetadata ('Postgres 'Vanilla) -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ Functions ('Postgres 'Vanilla)
InsOrdHashMap
QualifiedFunction (FunctionMetadata ('Postgres 'Vanilla))
functions
((FunctionMetadata ('Postgres 'Vanilla) -> m ()) -> m ())
-> (FunctionMetadata ('Postgres 'Vanilla) -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \(FunctionMetadata FunctionName ('Postgres 'Vanilla)
function FunctionConfig ('Postgres 'Vanilla)
config [FunctionPermissionInfo]
_ Maybe Text
_) -> QualifiedFunction -> FunctionConfig ('Postgres 'Vanilla) -> m ()
forall (m :: * -> *).
(MonadTx m, MonadReader SystemDefined m) =>
QualifiedFunction -> FunctionConfig ('Postgres 'Vanilla) -> m ()
addFunctionToCatalog FunctionName ('Postgres 'Vanilla)
QualifiedFunction
function FunctionConfig ('Postgres 'Vanilla)
config
SystemDefined
systemDefined <- m SystemDefined
forall r (m :: * -> *). MonadReader r m => m r
ask
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"query_collections"
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ QueryCollections -> (CreateCollection -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ QueryCollections
collections
((CreateCollection -> m ()) -> m ())
-> (CreateCollection -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \CreateCollection
c -> TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx (TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ CreateCollection -> SystemDefined -> TxE QErr ()
forall (m :: * -> *).
MonadTx m =>
CreateCollection -> SystemDefined -> m ()
addCollectionToCatalog CreateCollection
c SystemDefined
systemDefined
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"allowlist" (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ do
MetadataAllowlist -> (AllowlistEntry -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ MetadataAllowlist
allowlist ((AllowlistEntry -> m ()) -> m ())
-> (AllowlistEntry -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \(AllowlistEntry CollectionName
collectionName AllowlistScope
scope) -> do
Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (AllowlistScope
scope AllowlistScope -> AllowlistScope -> Bool
forall a. Eq a => a -> a -> Bool
== AllowlistScope
AllowlistScopeGlobal)
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ Code -> Text -> m ()
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotSupported
(Text -> m ()) -> Text -> m ()
forall a b. (a -> b) -> a -> b
$ Text
"cannot downgrade to v1 because the "
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> CollectionName
collectionName
CollectionName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" added to the allowlist is a role based allowlist"
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx (TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ CollectionName -> TxE QErr ()
forall (m :: * -> *). MonadTx m => CollectionName -> m ()
addCollectionToAllowlistCatalog CollectionName
collectionName
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"remote_schemas"
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ (RemoteSchemaMetadata -> m ()) -> RemoteSchemas -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
(a -> m b) -> t a -> m ()
indexedMapM_ (TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx (TxE QErr () -> m ())
-> (RemoteSchemaMetadata -> TxE QErr ())
-> RemoteSchemaMetadata
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RemoteSchemaMetadata -> TxE QErr ()
addRemoteSchemaToCatalog) RemoteSchemas
schemas
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"custom_types" (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ CustomTypes -> m ()
forall (m :: * -> *). MonadTx m => CustomTypes -> m ()
setCustomTypesInCatalog CustomTypes
customTypes
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"cron_triggers"
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ CronTriggers -> (CronTriggerMetadata -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ CronTriggers
cronTriggers
((CronTriggerMetadata -> m ()) -> m ())
-> (CronTriggerMetadata -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \CronTriggerMetadata
ct -> TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx (TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ do
CronTriggerMetadata -> TxE QErr ()
forall (m :: * -> *). MonadTx m => CronTriggerMetadata -> m ()
addCronTriggerToCatalog CronTriggerMetadata
ct
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"actions"
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ Actions -> (ActionMetadata -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ Actions
actions
((ActionMetadata -> m ()) -> m ())
-> (ActionMetadata -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \ActionMetadata
action -> do
let createAction :: CreateAction
createAction =
ActionName -> ActionDefinitionInput -> Maybe Text -> CreateAction
CreateAction (ActionMetadata -> ActionName
_amName ActionMetadata
action) (ActionMetadata -> ActionDefinitionInput
_amDefinition ActionMetadata
action) (ActionMetadata -> Maybe Text
_amComment ActionMetadata
action)
CreateAction -> m ()
forall (m :: * -> *). MonadTx m => CreateAction -> m ()
addActionToCatalog CreateAction
createAction
Text -> m () -> m ()
forall (m :: * -> *) a. QErrM m => Text -> m a -> m a
withPathK Text
"permissions"
(m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ [ActionPermissionMetadata]
-> (ActionPermissionMetadata -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ (ActionMetadata -> [ActionPermissionMetadata]
_amPermissions ActionMetadata
action)
((ActionPermissionMetadata -> m ()) -> m ())
-> (ActionPermissionMetadata -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \ActionPermissionMetadata
permission -> do
let createActionPermission :: CreateActionPermission
createActionPermission =
ActionName
-> RoleName -> Maybe Value -> Maybe Text -> CreateActionPermission
CreateActionPermission
(ActionMetadata -> ActionName
_amName ActionMetadata
action)
(ActionPermissionMetadata -> RoleName
_apmRole ActionPermissionMetadata
permission)
Maybe Value
forall a. Maybe a
Nothing
(ActionPermissionMetadata -> Maybe Text
_apmComment ActionPermissionMetadata
permission)
CreateActionPermission -> m ()
forall (m :: * -> *). MonadTx m => CreateActionPermission -> m ()
addActionPermissionToCatalog CreateActionPermission
createActionPermission
where
processPerms :: QualifiedTable -> t (PermDef b a) -> m ()
processPerms QualifiedTable
tableName t (PermDef b a)
perms = t (PermDef b a) -> (PermDef b a -> m ()) -> m ()
forall (m :: * -> *) (t :: * -> *) a b.
(QErrM m, Foldable t) =>
t a -> (a -> m b) -> m ()
indexedForM_ t (PermDef b a)
perms ((PermDef b a -> m ()) -> m ()) -> (PermDef b a -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \PermDef b a
perm -> do
SystemDefined
systemDefined <- m SystemDefined
forall r (m :: * -> *). MonadReader r m => m r
ask
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx (TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ QualifiedTable -> PermDef b a -> SystemDefined -> TxE QErr ()
forall (m :: * -> *) (b :: BackendType) (a :: BackendType -> *).
(MonadTx m, Backend b) =>
QualifiedTable -> PermDef b a -> SystemDefined -> m ()
addPermissionToCatalog QualifiedTable
tableName PermDef b a
perm SystemDefined
systemDefined
saveTableToCatalog ::
(MonadTx m, MonadReader SystemDefined m) => QualifiedTable -> Bool -> TableConfig ('Postgres 'Vanilla) -> m ()
saveTableToCatalog :: forall (m :: * -> *).
(MonadTx m, MonadReader SystemDefined m) =>
QualifiedTable -> Bool -> TableConfig ('Postgres 'Vanilla) -> m ()
saveTableToCatalog (QualifiedObject SchemaName
sn TableName
tn) Bool
isEnum TableConfig ('Postgres 'Vanilla)
config = do
SystemDefined
systemDefined <- m SystemDefined
forall r (m :: * -> *). MonadReader r m => m r
ask
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx
(TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr)
-> Query
-> (SchemaName, TableName, SystemDefined, Bool, ViaJSON Value)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT INTO "hdb_catalog"."hdb_table"
(table_schema, table_name, is_system_defined, is_enum, configuration)
VALUES ($1, $2, $3, $4, $5)
|]
(SchemaName
sn, TableName
tn, SystemDefined
systemDefined, Bool
isEnum, ViaJSON Value
configVal)
Bool
False
where
configVal :: ViaJSON Value
configVal = Value -> ViaJSON Value
forall a. a -> ViaJSON a
PG.ViaJSON (Value -> ViaJSON Value) -> Value -> ViaJSON Value
forall a b. (a -> b) -> a -> b
$ TableConfig ('Postgres 'Vanilla) -> Value
forall a. ToJSON a => a -> Value
toJSON TableConfig ('Postgres 'Vanilla)
config
insertRelationshipToCatalog ::
(MonadTx m, MonadReader SystemDefined m, ToJSON a) =>
QualifiedTable ->
RelType ->
RelDef a ->
m ()
insertRelationshipToCatalog :: forall (m :: * -> *) a.
(MonadTx m, MonadReader SystemDefined m, ToJSON a) =>
QualifiedTable -> RelType -> RelDef a -> m ()
insertRelationshipToCatalog (QualifiedObject SchemaName
schema TableName
table) RelType
relType (RelDef RelName
name a
using Maybe Text
comment) = do
SystemDefined
systemDefined <- m SystemDefined
forall r (m :: * -> *). MonadReader r m => m r
ask
let args :: (SchemaName, TableName, RelName, Text, ViaJSON a, Maybe Text,
SystemDefined)
args = (SchemaName
schema, TableName
table, RelName
name, RelType -> Text
relTypeToTxt RelType
relType, a -> ViaJSON a
forall a. a -> ViaJSON a
PG.ViaJSON a
using, Maybe Text
comment, SystemDefined
systemDefined)
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx (TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr)
-> Query
-> (SchemaName, TableName, RelName, Text, ViaJSON a, Maybe Text,
SystemDefined)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE PGTxErr -> QErr
defaultTxErrorHandler Query
query (SchemaName, TableName, RelName, Text, ViaJSON a, Maybe Text,
SystemDefined)
args Bool
True
where
query :: Query
query =
[PG.sql|
INSERT INTO
hdb_catalog.hdb_relationship
(table_schema, table_name, rel_name, rel_type, rel_def, comment, is_system_defined)
VALUES ($1, $2, $3, $4, $5 :: jsonb, $6, $7) |]
addEventTriggerToCatalog ::
(MonadTx m, Backend ('Postgres pgKind)) =>
QualifiedTable ->
EventTriggerConf ('Postgres pgKind) ->
m ()
addEventTriggerToCatalog :: forall (m :: * -> *) (pgKind :: PostgresKind).
(MonadTx m, Backend ('Postgres pgKind)) =>
QualifiedTable -> EventTriggerConf ('Postgres pgKind) -> m ()
addEventTriggerToCatalog QualifiedTable
qt EventTriggerConf ('Postgres pgKind)
etc = TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx do
(PGTxErr -> QErr)
-> Query
-> (TriggerName, SchemaName, TableName, ViaJSON Value)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT into hdb_catalog.event_triggers
(name, type, schema_name, table_name, configuration)
VALUES ($1, 'table', $2, $3, $4)
|]
(TriggerName
name, SchemaName
sn, TableName
tn, Value -> ViaJSON Value
forall a. a -> ViaJSON a
PG.ViaJSON (Value -> ViaJSON Value) -> Value -> ViaJSON Value
forall a b. (a -> b) -> a -> b
$ EventTriggerConf ('Postgres pgKind) -> Value
forall a. ToJSON a => a -> Value
toJSON EventTriggerConf ('Postgres pgKind)
etc)
Bool
False
where
QualifiedObject SchemaName
sn TableName
tn = QualifiedTable
qt
(EventTriggerConf TriggerName
name TriggerOpsDef ('Postgres pgKind)
_ Maybe InputWebhook
_ Maybe Text
_ RetryConf
_ Maybe [HeaderConf]
_ Maybe RequestTransform
_ Maybe MetadataResponseTransform
_ Maybe AutoTriggerLogCleanupConfig
_ TriggerOnReplication
_) = EventTriggerConf ('Postgres pgKind)
etc
addComputedFieldToCatalog ::
(MonadTx m) =>
AddComputedField ('Postgres 'Vanilla) ->
m ()
addComputedFieldToCatalog :: forall (m :: * -> *).
MonadTx m =>
AddComputedField ('Postgres 'Vanilla) -> m ()
addComputedFieldToCatalog AddComputedField ('Postgres 'Vanilla)
q =
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx
(TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr)
-> Query
-> (SchemaName, TableName, ComputedFieldName,
ViaJSON ComputedFieldDefinition, Maybe Text)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT INTO hdb_catalog.hdb_computed_field
(table_schema, table_name, computed_field_name, definition, commentText)
VALUES ($1, $2, $3, $4, $5)
|]
(SchemaName
schemaName, TableName
tableName, ComputedFieldName
computedField, ComputedFieldDefinition -> ViaJSON ComputedFieldDefinition
forall a. a -> ViaJSON a
PG.ViaJSON ComputedFieldDefinition ('Postgres 'Vanilla)
ComputedFieldDefinition
definition, Maybe Text
commentText)
Bool
True
where
commentText :: Maybe Text
commentText = Comment -> Maybe Text
commentToMaybeText Comment
comment
QualifiedObject SchemaName
schemaName TableName
tableName = TableName ('Postgres 'Vanilla)
table
AddComputedField SourceName
_ TableName ('Postgres 'Vanilla)
table ComputedFieldName
computedField ComputedFieldDefinition ('Postgres 'Vanilla)
definition Comment
comment = AddComputedField ('Postgres 'Vanilla)
q
addRemoteRelationshipToCatalog :: (MonadTx m) => CreateFromSourceRelationship ('Postgres 'Vanilla) -> m ()
addRemoteRelationshipToCatalog :: forall (m :: * -> *).
MonadTx m =>
CreateFromSourceRelationship ('Postgres 'Vanilla) -> m ()
addRemoteRelationshipToCatalog CreateFromSourceRelationship {SourceName
RelName
TableName ('Postgres 'Vanilla)
RemoteRelationshipDefinition
_crrSource :: SourceName
_crrTable :: TableName ('Postgres 'Vanilla)
_crrName :: RelName
_crrDefinition :: RemoteRelationshipDefinition
_crrSource :: forall (b :: BackendType).
CreateFromSourceRelationship b -> SourceName
_crrTable :: forall (b :: BackendType).
CreateFromSourceRelationship b -> TableName b
_crrName :: forall (b :: BackendType).
CreateFromSourceRelationship b -> RelName
_crrDefinition :: forall (b :: BackendType).
CreateFromSourceRelationship b -> RemoteRelationshipDefinition
..} =
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx
(TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr)
-> Query
-> (RelName, SchemaName, TableName,
ViaJSON RemoteRelationshipDefinition)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT INTO hdb_catalog.hdb_remote_relationship
(remote_relationship_name, table_schema, table_name, definition)
VALUES ($1, $2, $3, $4::jsonb)
|]
(RelName
_crrName, SchemaName
schemaName, TableName
tableName, RemoteRelationshipDefinition
-> ViaJSON RemoteRelationshipDefinition
forall a. a -> ViaJSON a
PG.ViaJSON RemoteRelationshipDefinition
_crrDefinition)
Bool
True
where
QualifiedObject SchemaName
schemaName TableName
tableName = TableName ('Postgres 'Vanilla)
_crrTable
addFunctionToCatalog ::
(MonadTx m, MonadReader SystemDefined m) =>
QualifiedFunction ->
FunctionConfig ('Postgres 'Vanilla) ->
m ()
addFunctionToCatalog :: forall (m :: * -> *).
(MonadTx m, MonadReader SystemDefined m) =>
QualifiedFunction -> FunctionConfig ('Postgres 'Vanilla) -> m ()
addFunctionToCatalog (QualifiedObject SchemaName
sn FunctionName
fn) FunctionConfig ('Postgres 'Vanilla)
config = do
SystemDefined
systemDefined <- m SystemDefined
forall r (m :: * -> *). MonadReader r m => m r
ask
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx
(TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr)
-> Query
-> (SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)), SystemDefined)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT INTO "hdb_catalog"."hdb_function"
(function_schema, function_name, configuration, is_system_defined)
VALUES ($1, $2, $3, $4)
|]
(SchemaName
sn, FunctionName
fn, FunctionConfig ('Postgres 'Vanilla)
-> ViaJSON (FunctionConfig ('Postgres 'Vanilla))
forall a. a -> ViaJSON a
PG.ViaJSON FunctionConfig ('Postgres 'Vanilla)
config, SystemDefined
systemDefined)
Bool
False
addRemoteSchemaToCatalog ::
RemoteSchemaMetadata ->
PG.TxE QErr ()
addRemoteSchemaToCatalog :: RemoteSchemaMetadata -> TxE QErr ()
addRemoteSchemaToCatalog (RemoteSchemaMetadata RemoteSchemaName
name RemoteSchemaDef
def Maybe Text
comment [RemoteSchemaPermissionMetadata]
_ SchemaRemoteRelationships RemoteRelationshipDefinition
_) =
(PGTxErr -> QErr)
-> Query
-> (RemoteSchemaName, ViaJSON Value, Maybe Text)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT into hdb_catalog.remote_schemas
(name, definition, comment)
VALUES ($1, $2, $3)
|]
(RemoteSchemaName
name, Value -> ViaJSON Value
forall a. a -> ViaJSON a
PG.ViaJSON (Value -> ViaJSON Value) -> Value -> ViaJSON Value
forall a b. (a -> b) -> a -> b
$ RemoteSchemaDef -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteSchemaDef
def, Maybe Text
comment)
Bool
True
addCollectionToCatalog ::
(MonadTx m) => CreateCollection -> SystemDefined -> m ()
addCollectionToCatalog :: forall (m :: * -> *).
MonadTx m =>
CreateCollection -> SystemDefined -> m ()
addCollectionToCatalog (CreateCollection CollectionName
name CollectionDef
defn Maybe Text
mComment) SystemDefined
systemDefined =
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx
(TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr)
-> Query
-> (CollectionName, ViaJSON CollectionDef, Maybe Text,
SystemDefined)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT INTO hdb_catalog.hdb_query_collection
(collection_name, collection_defn, comment, is_system_defined)
VALUES ($1, $2, $3, $4)
|]
(CollectionName
name, CollectionDef -> ViaJSON CollectionDef
forall a. a -> ViaJSON a
PG.ViaJSON CollectionDef
defn, Maybe Text
mComment, SystemDefined
systemDefined)
Bool
True
addCollectionToAllowlistCatalog :: (MonadTx m) => CollectionName -> m ()
addCollectionToAllowlistCatalog :: forall (m :: * -> *). MonadTx m => CollectionName -> m ()
addCollectionToAllowlistCatalog CollectionName
collName =
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx
(TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr)
-> Query -> Identity CollectionName -> Bool -> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT INTO hdb_catalog.hdb_allowlist
(collection_name)
VALUES ($1)
|]
(CollectionName -> Identity CollectionName
forall a. a -> Identity a
Identity CollectionName
collName)
Bool
True
setCustomTypesInCatalog :: (MonadTx m) => CustomTypes -> m ()
setCustomTypesInCatalog :: forall (m :: * -> *). MonadTx m => CustomTypes -> m ()
setCustomTypesInCatalog CustomTypes
customTypes = TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx do
TxE QErr ()
clearCustomTypes
(PGTxErr -> QErr)
-> Query -> Identity (ViaJSON CustomTypes) -> Bool -> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT into hdb_catalog.hdb_custom_types
(custom_types)
VALUES ($1)
|]
(ViaJSON CustomTypes -> Identity (ViaJSON CustomTypes)
forall a. a -> Identity a
Identity (ViaJSON CustomTypes -> Identity (ViaJSON CustomTypes))
-> ViaJSON CustomTypes -> Identity (ViaJSON CustomTypes)
forall a b. (a -> b) -> a -> b
$ CustomTypes -> ViaJSON CustomTypes
forall a. a -> ViaJSON a
PG.ViaJSON CustomTypes
customTypes)
Bool
False
where
clearCustomTypes :: TxE QErr ()
clearCustomTypes = do
(PGTxErr -> QErr) -> Query -> () -> Bool -> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
DELETE FROM hdb_catalog.hdb_custom_types
|]
()
Bool
False
addActionToCatalog :: (MonadTx m) => CreateAction -> m ()
addActionToCatalog :: forall (m :: * -> *). MonadTx m => CreateAction -> m ()
addActionToCatalog (CreateAction ActionName
actionName ActionDefinitionInput
actionDefinition Maybe Text
comment) = do
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx
(TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr)
-> Query
-> (ActionName, ViaJSON ActionDefinitionInput, Maybe Text)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT into hdb_catalog.hdb_action
(action_name, action_defn, comment)
VALUES ($1, $2, $3)
|]
(ActionName
actionName, ActionDefinitionInput -> ViaJSON ActionDefinitionInput
forall a. a -> ViaJSON a
PG.ViaJSON ActionDefinitionInput
actionDefinition, Maybe Text
comment)
Bool
True
addActionPermissionToCatalog :: (MonadTx m) => CreateActionPermission -> m ()
addActionPermissionToCatalog :: forall (m :: * -> *). MonadTx m => CreateActionPermission -> m ()
addActionPermissionToCatalog CreateActionPermission {Maybe Text
Maybe Value
RoleName
ActionName
_capAction :: ActionName
_capRole :: RoleName
_capDefinition :: Maybe Value
_capComment :: Maybe Text
_capAction :: CreateActionPermission -> ActionName
_capRole :: CreateActionPermission -> RoleName
_capDefinition :: CreateActionPermission -> Maybe Value
_capComment :: CreateActionPermission -> Maybe Text
..} = do
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx
(TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr)
-> Query
-> (ActionName, RoleName, Maybe Text)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT into hdb_catalog.hdb_action_permission
(action_name, role_name, comment)
VALUES ($1, $2, $3)
|]
(ActionName
_capAction, RoleName
_capRole, Maybe Text
_capComment)
Bool
True
addPermissionToCatalog ::
(MonadTx m, Backend b) =>
QualifiedTable ->
PermDef b a ->
SystemDefined ->
m ()
addPermissionToCatalog :: forall (m :: * -> *) (b :: BackendType) (a :: BackendType -> *).
(MonadTx m, Backend b) =>
QualifiedTable -> PermDef b a -> SystemDefined -> m ()
addPermissionToCatalog (QualifiedObject SchemaName
sn TableName
tn) (PermDef RoleName
rn PermDefPermission b a
qdef Maybe Text
mComment) SystemDefined
systemDefined =
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx
(TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr)
-> Query
-> (SchemaName, TableName, RoleName, Text,
ViaJSON (PermDefPermission b a), Maybe Text, SystemDefined)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT INTO
hdb_catalog.hdb_permission
(table_schema, table_name, role_name, perm_type, perm_def, comment, is_system_defined)
VALUES ($1, $2, $3, $4, $5 :: jsonb, $6, $7)
|]
(SchemaName
sn, TableName
tn, RoleName
rn, PermType -> Text
permTypeToCode (PermDefPermission b a -> PermType
forall (b :: BackendType) (a :: BackendType -> *).
PermDefPermission b a -> PermType
reflectPermDefPermission PermDefPermission b a
qdef), PermDefPermission b a -> ViaJSON (PermDefPermission b a)
forall a. a -> ViaJSON a
PG.ViaJSON PermDefPermission b a
qdef, Maybe Text
mComment, SystemDefined
systemDefined)
Bool
True
addCronTriggerToCatalog :: (MonadTx m) => CronTriggerMetadata -> m ()
addCronTriggerToCatalog :: forall (m :: * -> *). MonadTx m => CronTriggerMetadata -> m ()
addCronTriggerToCatalog CronTriggerMetadata {Bool
[HeaderConf]
Maybe Text
Maybe Value
Maybe RequestTransform
Maybe MetadataResponseTransform
CronSchedule
InputWebhook
TriggerName
STRetryConf
ctName :: TriggerName
ctWebhook :: InputWebhook
ctSchedule :: CronSchedule
ctPayload :: Maybe Value
ctRetryConf :: STRetryConf
ctHeaders :: [HeaderConf]
ctIncludeInMetadata :: Bool
ctComment :: Maybe Text
ctRequestTransform :: Maybe RequestTransform
ctResponseTransform :: Maybe MetadataResponseTransform
ctName :: CronTriggerMetadata -> TriggerName
ctWebhook :: CronTriggerMetadata -> InputWebhook
ctSchedule :: CronTriggerMetadata -> CronSchedule
ctPayload :: CronTriggerMetadata -> Maybe Value
ctRetryConf :: CronTriggerMetadata -> STRetryConf
ctHeaders :: CronTriggerMetadata -> [HeaderConf]
ctIncludeInMetadata :: CronTriggerMetadata -> Bool
ctComment :: CronTriggerMetadata -> Maybe Text
ctRequestTransform :: CronTriggerMetadata -> Maybe RequestTransform
ctResponseTransform :: CronTriggerMetadata -> Maybe MetadataResponseTransform
..} = TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx (TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ do
(PGTxErr -> QErr)
-> Query
-> (TriggerName, ViaJSON InputWebhook, CronSchedule,
Maybe (ViaJSON Value), ViaJSON STRetryConf, ViaJSON [HeaderConf],
Bool, Maybe Text)
-> Bool
-> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
INSERT into hdb_catalog.hdb_cron_triggers
(name, webhook_conf, cron_schedule, payload, retry_conf, header_conf, include_in_metadata, comment)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|]
( TriggerName
ctName,
InputWebhook -> ViaJSON InputWebhook
forall a. a -> ViaJSON a
PG.ViaJSON InputWebhook
ctWebhook,
CronSchedule
ctSchedule,
Value -> ViaJSON Value
forall a. a -> ViaJSON a
PG.ViaJSON (Value -> ViaJSON Value) -> Maybe Value -> Maybe (ViaJSON Value)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Value
ctPayload,
STRetryConf -> ViaJSON STRetryConf
forall a. a -> ViaJSON a
PG.ViaJSON STRetryConf
ctRetryConf,
[HeaderConf] -> ViaJSON [HeaderConf]
forall a. a -> ViaJSON a
PG.ViaJSON [HeaderConf]
ctHeaders,
Bool
ctIncludeInMetadata,
Maybe Text
ctComment
)
Bool
False
UTCTime
currentTime <- IO UTCTime -> TxET QErr IO UTCTime
forall a. IO a -> TxET QErr IO a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO UTCTime
C.getCurrentTime
let scheduleTimes :: [UTCTime]
scheduleTimes = UTCTime -> Int -> CronSchedule -> [UTCTime]
generateScheduleTimes UTCTime
currentTime Int
100 CronSchedule
ctSchedule
[CronEventSeed] -> TxE QErr ()
insertCronEventsTx ([CronEventSeed] -> TxE QErr ()) -> [CronEventSeed] -> TxE QErr ()
forall a b. (a -> b) -> a -> b
$ (UTCTime -> CronEventSeed) -> [UTCTime] -> [CronEventSeed]
forall a b. (a -> b) -> [a] -> [b]
map (TriggerName -> UTCTime -> CronEventSeed
CronEventSeed TriggerName
ctName) [UTCTime]
scheduleTimes
parseLegacyRemoteRelationshipDefinition ::
(MonadError QErr m) =>
Value ->
m RemoteRelationshipDefinition
parseLegacyRemoteRelationshipDefinition :: forall (m :: * -> *).
MonadError QErr m =>
Value -> m RemoteRelationshipDefinition
parseLegacyRemoteRelationshipDefinition =
(Value -> Parser RemoteRelationshipDefinition)
-> Value -> m RemoteRelationshipDefinition
forall (m :: * -> *) v a. QErrM m => (v -> Parser a) -> v -> m a
runAesonParser (RRParseMode -> Value -> Parser RemoteRelationshipDefinition
parseRemoteRelationshipDefinition RRParseMode
RRPLegacy)
fetchMetadataFromHdbTables :: (MonadTx m) => m MetadataNoSources
fetchMetadataFromHdbTables :: forall (m :: * -> *). MonadTx m => m MetadataNoSources
fetchMetadataFromHdbTables = TxE QErr MetadataNoSources -> m MetadataNoSources
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx do
[(SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))]
tables <- TxET
QErr
IO
[(SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))]
fetchTables
let tableMetaMap :: InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla))
tableMetaMap = [(QualifiedTable, TableMetadata ('Postgres 'Vanilla))]
-> InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))
forall k v. (Eq k, Hashable k) => [(k, v)] -> InsOrdHashMap k v
InsOrdHashMap.fromList
([(QualifiedTable, TableMetadata ('Postgres 'Vanilla))]
-> InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> (((SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))
-> (QualifiedTable, TableMetadata ('Postgres 'Vanilla)))
-> [(QualifiedTable, TableMetadata ('Postgres 'Vanilla))])
-> ((SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))
-> (QualifiedTable, TableMetadata ('Postgres 'Vanilla)))
-> InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (((SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))
-> (QualifiedTable, TableMetadata ('Postgres 'Vanilla)))
-> [(SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))]
-> [(QualifiedTable, TableMetadata ('Postgres 'Vanilla))])
-> [(SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))]
-> ((SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))
-> (QualifiedTable, TableMetadata ('Postgres 'Vanilla)))
-> [(QualifiedTable, TableMetadata ('Postgres 'Vanilla))]
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))
-> (QualifiedTable, TableMetadata ('Postgres 'Vanilla)))
-> [(SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))]
-> [(QualifiedTable, TableMetadata ('Postgres 'Vanilla))]
forall a b. (a -> b) -> [a] -> [b]
map [(SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))]
tables
(((SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))
-> (QualifiedTable, TableMetadata ('Postgres 'Vanilla)))
-> InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> ((SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))
-> (QualifiedTable, TableMetadata ('Postgres 'Vanilla)))
-> InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ \(SchemaName
schema, TableName
name, Bool
isEnum, Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla)))
maybeConfig) ->
let qualifiedName :: QualifiedTable
qualifiedName = SchemaName -> TableName -> QualifiedTable
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
schema TableName
name
configuration :: TableConfig ('Postgres 'Vanilla)
configuration = TableConfig ('Postgres 'Vanilla)
-> (ViaJSON (TableConfig ('Postgres 'Vanilla))
-> TableConfig ('Postgres 'Vanilla))
-> Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla)))
-> TableConfig ('Postgres 'Vanilla)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe TableConfig ('Postgres 'Vanilla)
forall (b :: BackendType). TableConfig b
emptyTableConfig ViaJSON (TableConfig ('Postgres 'Vanilla))
-> TableConfig ('Postgres 'Vanilla)
forall a. ViaJSON a -> a
PG.getViaJSON Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla)))
maybeConfig
in (QualifiedTable
qualifiedName, TableName ('Postgres 'Vanilla)
-> Bool
-> TableConfig ('Postgres 'Vanilla)
-> TableMetadata ('Postgres 'Vanilla)
forall (b :: BackendType).
TableName b -> Bool -> TableConfig b -> TableMetadata b
mkTableMeta TableName ('Postgres 'Vanilla)
QualifiedTable
qualifiedName Bool
isEnum TableConfig ('Postgres 'Vanilla)
configuration)
[(SchemaName, TableName, RelName, RelType, ViaJSON Value,
Maybe Text)]
relationships <- TxET
QErr
IO
[(SchemaName, TableName, RelName, RelType, ViaJSON Value,
Maybe Text)]
fetchRelationships
[(QualifiedTable, ObjRelDef ('Postgres 'Vanilla))]
objRelDefs <- RelType
-> [(SchemaName, TableName, RelName, RelType, ViaJSON Value,
Maybe Text)]
-> TxET QErr IO [(QualifiedTable, ObjRelDef ('Postgres 'Vanilla))]
forall {m :: * -> *} {a} {d} {a}.
(MonadError QErr m, FromJSON a, Eq d) =>
d
-> [(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, RelDef a)]
mkRelDefs RelType
ObjRel [(SchemaName, TableName, RelName, RelType, ViaJSON Value,
Maybe Text)]
relationships
[(QualifiedTable, ArrRelDef ('Postgres 'Vanilla))]
arrRelDefs <- RelType
-> [(SchemaName, TableName, RelName, RelType, ViaJSON Value,
Maybe Text)]
-> TxET QErr IO [(QualifiedTable, ArrRelDef ('Postgres 'Vanilla))]
forall {m :: * -> *} {a} {d} {a}.
(MonadError QErr m, FromJSON a, Eq d) =>
d
-> [(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, RelDef a)]
mkRelDefs RelType
ArrRel [(SchemaName, TableName, RelName, RelType, ViaJSON Value,
Maybe Text)]
relationships
[(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
permissions <- TxET
QErr
IO
[(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
fetchPermissions
[(QualifiedTable, InsPermDef ('Postgres 'Vanilla))]
insPermDefs <- PermType
-> [(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
-> TxET QErr IO [(QualifiedTable, InsPermDef ('Postgres 'Vanilla))]
forall {m :: * -> *} {b :: BackendType} {perm :: BackendType -> *}
{d} {a}.
(MonadError QErr m, FromJSON (PermDefPermission b perm), Eq d) =>
d
-> [(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, PermDef b perm)]
mkPermDefs PermType
PTInsert [(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
permissions
[(QualifiedTable, SelPermDef ('Postgres 'Vanilla))]
selPermDefs <- PermType
-> [(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
-> TxET QErr IO [(QualifiedTable, SelPermDef ('Postgres 'Vanilla))]
forall {m :: * -> *} {b :: BackendType} {perm :: BackendType -> *}
{d} {a}.
(MonadError QErr m, FromJSON (PermDefPermission b perm), Eq d) =>
d
-> [(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, PermDef b perm)]
mkPermDefs PermType
PTSelect [(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
permissions
[(QualifiedTable, UpdPermDef ('Postgres 'Vanilla))]
updPermDefs <- PermType
-> [(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
-> TxET QErr IO [(QualifiedTable, UpdPermDef ('Postgres 'Vanilla))]
forall {m :: * -> *} {b :: BackendType} {perm :: BackendType -> *}
{d} {a}.
(MonadError QErr m, FromJSON (PermDefPermission b perm), Eq d) =>
d
-> [(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, PermDef b perm)]
mkPermDefs PermType
PTUpdate [(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
permissions
[(QualifiedTable, DelPermDef ('Postgres 'Vanilla))]
delPermDefs <- PermType
-> [(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
-> TxET QErr IO [(QualifiedTable, DelPermDef ('Postgres 'Vanilla))]
forall {m :: * -> *} {b :: BackendType} {perm :: BackendType -> *}
{d} {a}.
(MonadError QErr m, FromJSON (PermDefPermission b perm), Eq d) =>
d
-> [(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, PermDef b perm)]
mkPermDefs PermType
PTDelete [(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
permissions
[(SchemaName, TableName, ViaJSON Value)]
eventTriggers :: [(SchemaName, Postgres.TableName, PG.ViaJSON Value)] <- TxET QErr IO [(SchemaName, TableName, ViaJSON Value)]
fetchEventTriggers
[(QualifiedTable, EventTriggerConf ('Postgres 'Vanilla))]
triggerMetaDefs <- [(SchemaName, TableName, ViaJSON Value)]
-> TxET
QErr IO [(QualifiedTable, EventTriggerConf ('Postgres 'Vanilla))]
forall {a}.
[(SchemaName, a, ViaJSON Value)]
-> TxET
QErr
IO
[(QualifiedObject a, EventTriggerConf ('Postgres 'Vanilla))]
mkTriggerMetaDefs [(SchemaName, TableName, ViaJSON Value)]
eventTriggers
[(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
computedFields <- TxET
QErr
IO
[(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
fetchComputedFields
[(QualifiedTable, RelName, Value)]
remoteRelationshipsRaw <- TxET QErr IO [(QualifiedTable, RelName, Value)]
fetchRemoteRelationships
[(QualifiedTable, RemoteRelationship)]
remoteRelationships <- [(QualifiedTable, RelName, Value)]
-> ((QualifiedTable, RelName, Value)
-> TxET QErr IO (QualifiedTable, RemoteRelationship))
-> TxET QErr IO [(QualifiedTable, RemoteRelationship)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for [(QualifiedTable, RelName, Value)]
remoteRelationshipsRaw (((QualifiedTable, RelName, Value)
-> TxET QErr IO (QualifiedTable, RemoteRelationship))
-> TxET QErr IO [(QualifiedTable, RemoteRelationship)])
-> ((QualifiedTable, RelName, Value)
-> TxET QErr IO (QualifiedTable, RemoteRelationship))
-> TxET QErr IO [(QualifiedTable, RemoteRelationship)]
forall a b. (a -> b) -> a -> b
$ \(QualifiedTable
table, RelName
relationshipName, Value
definitionValue) -> do
RemoteRelationshipDefinition
definition <- Value -> TxET QErr IO RemoteRelationshipDefinition
forall (m :: * -> *).
MonadError QErr m =>
Value -> m RemoteRelationshipDefinition
parseLegacyRemoteRelationshipDefinition Value
definitionValue
(QualifiedTable, RemoteRelationship)
-> TxET QErr IO (QualifiedTable, RemoteRelationship)
forall a. a -> TxET QErr IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((QualifiedTable, RemoteRelationship)
-> TxET QErr IO (QualifiedTable, RemoteRelationship))
-> (QualifiedTable, RemoteRelationship)
-> TxET QErr IO (QualifiedTable, RemoteRelationship)
forall a b. (a -> b) -> a -> b
$ (QualifiedTable
table, RelName -> RemoteRelationshipDefinition -> RemoteRelationship
forall definition.
RelName -> definition -> RemoteRelationshipG definition
RemoteRelationship RelName
relationshipName RemoteRelationshipDefinition
definition)
let (()
_, InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla))
fullTableMetaMap) = (State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
-> InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))
-> ((),
InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla))))
-> InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))
-> State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
-> ((),
InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
forall a b c. (a -> b -> c) -> b -> a -> c
flip State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
-> InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))
-> ((),
InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
forall s a. State s a -> s -> (a, s)
runState InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla))
tableMetaMap (State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
-> ((),
InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla))))
-> State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
-> ((),
InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
forall a b. (a -> b) -> a -> b
$ do
((Relationships (ObjRelDef ('Postgres 'Vanilla))
-> Identity (Relationships (ObjRelDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla)))))
-> (ObjRelDef ('Postgres 'Vanilla) -> RelName)
-> [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
ObjRelDef ('Postgres 'Vanilla))]
-> State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
forall {m :: * -> *} {a} {t :: * -> *} {k} {v}.
(MonadState a m, Foldable t, At a, Hashable k) =>
((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a))
-> (v -> k) -> t (Index a, v) -> m ()
modMetaMap (Relationships (ObjRelDef ('Postgres 'Vanilla))
-> Identity (Relationships (ObjRelDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))))
(Relationships (ObjRelDef ('Postgres 'Vanilla))
-> Identity (Relationships (ObjRelDef ('Postgres 'Vanilla))))
-> TableMetadata ('Postgres 'Vanilla)
-> Identity (TableMetadata ('Postgres 'Vanilla))
forall (b :: BackendType) (f :: * -> *).
Functor f =>
(Relationships (ObjRelDef b) -> f (Relationships (ObjRelDef b)))
-> TableMetadata b -> f (TableMetadata b)
tmObjectRelationships ObjRelDef ('Postgres 'Vanilla) -> RelName
forall a. RelDef a -> RelName
_rdName [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
ObjRelDef ('Postgres 'Vanilla))]
[(QualifiedTable, ObjRelDef ('Postgres 'Vanilla))]
objRelDefs
((Relationships (ArrRelDef ('Postgres 'Vanilla))
-> Identity (Relationships (ArrRelDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla)))))
-> (ArrRelDef ('Postgres 'Vanilla) -> RelName)
-> [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
ArrRelDef ('Postgres 'Vanilla))]
-> State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
forall {m :: * -> *} {a} {t :: * -> *} {k} {v}.
(MonadState a m, Foldable t, At a, Hashable k) =>
((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a))
-> (v -> k) -> t (Index a, v) -> m ()
modMetaMap (Relationships (ArrRelDef ('Postgres 'Vanilla))
-> Identity (Relationships (ArrRelDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))))
(Relationships (ArrRelDef ('Postgres 'Vanilla))
-> Identity (Relationships (ArrRelDef ('Postgres 'Vanilla))))
-> TableMetadata ('Postgres 'Vanilla)
-> Identity (TableMetadata ('Postgres 'Vanilla))
forall (b :: BackendType) (f :: * -> *).
Functor f =>
(Relationships (ArrRelDef b) -> f (Relationships (ArrRelDef b)))
-> TableMetadata b -> f (TableMetadata b)
tmArrayRelationships ArrRelDef ('Postgres 'Vanilla) -> RelName
forall a. RelDef a -> RelName
_rdName [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
ArrRelDef ('Postgres 'Vanilla))]
[(QualifiedTable, ArrRelDef ('Postgres 'Vanilla))]
arrRelDefs
((Permissions (InsPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (InsPermDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla)))))
-> (InsPermDef ('Postgres 'Vanilla) -> RoleName)
-> [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
InsPermDef ('Postgres 'Vanilla))]
-> State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
forall {m :: * -> *} {a} {t :: * -> *} {k} {v}.
(MonadState a m, Foldable t, At a, Hashable k) =>
((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a))
-> (v -> k) -> t (Index a, v) -> m ()
modMetaMap (Permissions (InsPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (InsPermDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))))
(Permissions (InsPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (InsPermDef ('Postgres 'Vanilla))))
-> TableMetadata ('Postgres 'Vanilla)
-> Identity (TableMetadata ('Postgres 'Vanilla))
forall (b :: BackendType) (f :: * -> *).
Functor f =>
(Permissions (InsPermDef b) -> f (Permissions (InsPermDef b)))
-> TableMetadata b -> f (TableMetadata b)
tmInsertPermissions InsPermDef ('Postgres 'Vanilla) -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
InsPermDef ('Postgres 'Vanilla))]
[(QualifiedTable, InsPermDef ('Postgres 'Vanilla))]
insPermDefs
((Permissions (SelPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (SelPermDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla)))))
-> (SelPermDef ('Postgres 'Vanilla) -> RoleName)
-> [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
SelPermDef ('Postgres 'Vanilla))]
-> State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
forall {m :: * -> *} {a} {t :: * -> *} {k} {v}.
(MonadState a m, Foldable t, At a, Hashable k) =>
((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a))
-> (v -> k) -> t (Index a, v) -> m ()
modMetaMap (Permissions (SelPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (SelPermDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))))
(Permissions (SelPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (SelPermDef ('Postgres 'Vanilla))))
-> TableMetadata ('Postgres 'Vanilla)
-> Identity (TableMetadata ('Postgres 'Vanilla))
forall (b :: BackendType) (f :: * -> *).
Functor f =>
(Permissions (SelPermDef b) -> f (Permissions (SelPermDef b)))
-> TableMetadata b -> f (TableMetadata b)
tmSelectPermissions SelPermDef ('Postgres 'Vanilla) -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
SelPermDef ('Postgres 'Vanilla))]
[(QualifiedTable, SelPermDef ('Postgres 'Vanilla))]
selPermDefs
((Permissions (UpdPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (UpdPermDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla)))))
-> (UpdPermDef ('Postgres 'Vanilla) -> RoleName)
-> [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
UpdPermDef ('Postgres 'Vanilla))]
-> State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
forall {m :: * -> *} {a} {t :: * -> *} {k} {v}.
(MonadState a m, Foldable t, At a, Hashable k) =>
((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a))
-> (v -> k) -> t (Index a, v) -> m ()
modMetaMap (Permissions (UpdPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (UpdPermDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))))
(Permissions (UpdPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (UpdPermDef ('Postgres 'Vanilla))))
-> TableMetadata ('Postgres 'Vanilla)
-> Identity (TableMetadata ('Postgres 'Vanilla))
forall (b :: BackendType) (f :: * -> *).
Functor f =>
(Permissions (UpdPermDef b) -> f (Permissions (UpdPermDef b)))
-> TableMetadata b -> f (TableMetadata b)
tmUpdatePermissions UpdPermDef ('Postgres 'Vanilla) -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
UpdPermDef ('Postgres 'Vanilla))]
[(QualifiedTable, UpdPermDef ('Postgres 'Vanilla))]
updPermDefs
((Permissions (DelPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (DelPermDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla)))))
-> (DelPermDef ('Postgres 'Vanilla) -> RoleName)
-> [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
DelPermDef ('Postgres 'Vanilla))]
-> State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
forall {m :: * -> *} {a} {t :: * -> *} {k} {v}.
(MonadState a m, Foldable t, At a, Hashable k) =>
((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a))
-> (v -> k) -> t (Index a, v) -> m ()
modMetaMap (Permissions (DelPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (DelPermDef ('Postgres 'Vanilla))))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))))
(Permissions (DelPermDef ('Postgres 'Vanilla))
-> Identity (Permissions (DelPermDef ('Postgres 'Vanilla))))
-> TableMetadata ('Postgres 'Vanilla)
-> Identity (TableMetadata ('Postgres 'Vanilla))
forall (b :: BackendType) (f :: * -> *).
Functor f =>
(Permissions (DelPermDef b) -> f (Permissions (DelPermDef b)))
-> TableMetadata b -> f (TableMetadata b)
tmDeletePermissions DelPermDef ('Postgres 'Vanilla) -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
DelPermDef ('Postgres 'Vanilla))]
[(QualifiedTable, DelPermDef ('Postgres 'Vanilla))]
delPermDefs
((EventTriggers ('Postgres 'Vanilla)
-> Identity (EventTriggers ('Postgres 'Vanilla)))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla)))))
-> (EventTriggerConf ('Postgres 'Vanilla) -> TriggerName)
-> [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
EventTriggerConf ('Postgres 'Vanilla))]
-> State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
forall {m :: * -> *} {a} {t :: * -> *} {k} {v}.
(MonadState a m, Foldable t, At a, Hashable k) =>
((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a))
-> (v -> k) -> t (Index a, v) -> m ()
modMetaMap (EventTriggers ('Postgres 'Vanilla)
-> Identity (EventTriggers ('Postgres 'Vanilla)))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))))
(EventTriggers ('Postgres 'Vanilla)
-> Identity (EventTriggers ('Postgres 'Vanilla)))
-> TableMetadata ('Postgres 'Vanilla)
-> Identity (TableMetadata ('Postgres 'Vanilla))
forall (b :: BackendType) (f :: * -> *).
Functor f =>
(EventTriggers b -> f (EventTriggers b))
-> TableMetadata b -> f (TableMetadata b)
tmEventTriggers EventTriggerConf ('Postgres 'Vanilla) -> TriggerName
forall (b :: BackendType). EventTriggerConf b -> TriggerName
etcName [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
EventTriggerConf ('Postgres 'Vanilla))]
[(QualifiedTable, EventTriggerConf ('Postgres 'Vanilla))]
triggerMetaDefs
((ComputedFields ('Postgres 'Vanilla)
-> Identity (ComputedFields ('Postgres 'Vanilla)))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla)))))
-> (ComputedFieldMetadata ('Postgres 'Vanilla)
-> ComputedFieldName)
-> [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
ComputedFieldMetadata ('Postgres 'Vanilla))]
-> State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
forall {m :: * -> *} {a} {t :: * -> *} {k} {v}.
(MonadState a m, Foldable t, At a, Hashable k) =>
((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a))
-> (v -> k) -> t (Index a, v) -> m ()
modMetaMap (ComputedFields ('Postgres 'Vanilla)
-> Identity (ComputedFields ('Postgres 'Vanilla)))
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))))
(ComputedFields ('Postgres 'Vanilla)
-> Identity (ComputedFields ('Postgres 'Vanilla)))
-> TableMetadata ('Postgres 'Vanilla)
-> Identity (TableMetadata ('Postgres 'Vanilla))
forall (b :: BackendType) (f :: * -> *).
Functor f =>
(ComputedFields b -> f (ComputedFields b))
-> TableMetadata b -> f (TableMetadata b)
tmComputedFields ComputedFieldMetadata ('Postgres 'Vanilla) -> ComputedFieldName
forall (b :: BackendType).
ComputedFieldMetadata b -> ComputedFieldName
_cfmName [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
ComputedFieldMetadata ('Postgres 'Vanilla))]
[(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
computedFields
((RemoteRelationships -> Identity RemoteRelationships)
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla)))))
-> (RemoteRelationship -> RelName)
-> [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
RemoteRelationship)]
-> State
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
()
forall {m :: * -> *} {a} {t :: * -> *} {k} {v}.
(MonadState a m, Foldable t, At a, Hashable k) =>
((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a))
-> (v -> k) -> t (Index a, v) -> m ()
modMetaMap (RemoteRelationships -> Identity RemoteRelationships)
-> IxValue
(InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla)))
-> Identity
(IxValue
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))))
(RemoteRelationships -> Identity RemoteRelationships)
-> TableMetadata ('Postgres 'Vanilla)
-> Identity (TableMetadata ('Postgres 'Vanilla))
forall (b :: BackendType) (f :: * -> *).
Functor f =>
(RemoteRelationships -> f RemoteRelationships)
-> TableMetadata b -> f (TableMetadata b)
tmRemoteRelationships RemoteRelationship -> RelName
forall definition. RemoteRelationshipG definition -> RelName
_rrName [(Index
(InsOrdHashMap
QualifiedTable (TableMetadata ('Postgres 'Vanilla))),
RemoteRelationship)]
[(QualifiedTable, RemoteRelationship)]
remoteRelationships
Functions ('Postgres 'Vanilla)
functions <- TxET QErr IO (Functions ('Postgres 'Vanilla))
fetchFunctions
RemoteSchemas
remoteSchemas <- (RemoteSchemaMetadata -> RemoteSchemaName)
-> [RemoteSchemaMetadata] -> RemoteSchemas
forall k a. Hashable k => (a -> k) -> [a] -> InsOrdHashMap k a
oMapFromL RemoteSchemaMetadata -> RemoteSchemaName
forall r. RemoteSchemaMetadataG r -> RemoteSchemaName
_rsmName ([RemoteSchemaMetadata] -> RemoteSchemas)
-> TxET QErr IO [RemoteSchemaMetadata]
-> TxET QErr IO RemoteSchemas
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TxET QErr IO [RemoteSchemaMetadata]
forall {r}. TxET QErr IO [RemoteSchemaMetadataG r]
fetchRemoteSchemas
QueryCollections
collections <- (CreateCollection -> CollectionName)
-> [CreateCollection] -> QueryCollections
forall k a. Hashable k => (a -> k) -> [a] -> InsOrdHashMap k a
oMapFromL CreateCollection -> CollectionName
_ccName ([CreateCollection] -> QueryCollections)
-> TxET QErr IO [CreateCollection] -> TxET QErr IO QueryCollections
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TxET QErr IO [CreateCollection]
fetchCollections
MetadataAllowlist
allowlist <- (AllowlistEntry -> CollectionName)
-> [AllowlistEntry] -> MetadataAllowlist
forall k a. Hashable k => (a -> k) -> [a] -> InsOrdHashMap k a
oMapFromL AllowlistEntry -> CollectionName
aeCollection ([AllowlistEntry] -> MetadataAllowlist)
-> TxET QErr IO [AllowlistEntry] -> TxET QErr IO MetadataAllowlist
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TxET QErr IO [AllowlistEntry]
fetchAllowlist
CustomTypes
customTypes <- TxE QErr CustomTypes
fetchCustomTypes
Actions
actions <- (ActionMetadata -> ActionName) -> [ActionMetadata] -> Actions
forall k a. Hashable k => (a -> k) -> [a] -> InsOrdHashMap k a
oMapFromL ActionMetadata -> ActionName
_amName ([ActionMetadata] -> Actions)
-> TxET QErr IO [ActionMetadata] -> TxET QErr IO Actions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TxET QErr IO [ActionMetadata]
fetchActions
CronTriggers
cronTriggers <- TxET QErr IO CronTriggers
fetchCronTriggers
MetadataNoSources -> TxE QErr MetadataNoSources
forall a. a -> TxET QErr IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
(MetadataNoSources -> TxE QErr MetadataNoSources)
-> MetadataNoSources -> TxE QErr MetadataNoSources
forall a b. (a -> b) -> a -> b
$ Tables ('Postgres 'Vanilla)
-> Functions ('Postgres 'Vanilla)
-> RemoteSchemas
-> QueryCollections
-> MetadataAllowlist
-> CustomTypes
-> Actions
-> CronTriggers
-> MetadataNoSources
MetadataNoSources
Tables ('Postgres 'Vanilla)
InsOrdHashMap QualifiedTable (TableMetadata ('Postgres 'Vanilla))
fullTableMetaMap
Functions ('Postgres 'Vanilla)
functions
RemoteSchemas
remoteSchemas
QueryCollections
collections
MetadataAllowlist
allowlist
CustomTypes
customTypes
Actions
actions
CronTriggers
cronTriggers
where
modMetaMap :: ((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a))
-> (v -> k) -> t (Index a, v) -> m ()
modMetaMap (InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a)
l v -> k
f t (Index a, v)
xs = do
a
st <- m a
forall s (m :: * -> *). MonadState s m => m s
get
a -> m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (a -> m ()) -> a -> m ()
forall a b. (a -> b) -> a -> b
$ (a -> (Index a, v) -> a) -> a -> t (Index a, v) -> a
forall b a. (b -> a -> b) -> b -> t a -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\a
b (Index a
qt, v
dfn) -> a
b a -> (a -> a) -> a
forall a b. a -> (a -> b) -> b
& Index a -> Lens' a (Maybe (IxValue a))
forall m. At m => Index m -> Lens' m (Maybe (IxValue m))
at Index a
qt ((Maybe (IxValue a) -> Identity (Maybe (IxValue a)))
-> a -> Identity a)
-> ((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> Maybe (IxValue a) -> Identity (Maybe (IxValue a)))
-> (InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> a
-> Identity a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IxValue a -> Identity (IxValue a))
-> Maybe (IxValue a) -> Identity (Maybe (IxValue a))
forall a b (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f b) -> p (Maybe a) (f (Maybe b))
_Just ((IxValue a -> Identity (IxValue a))
-> Maybe (IxValue a) -> Identity (Maybe (IxValue a)))
-> ((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a))
-> (InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> Maybe (IxValue a)
-> Identity (Maybe (IxValue a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> IxValue a -> Identity (IxValue a)
l ((InsOrdHashMap k v -> Identity (InsOrdHashMap k v))
-> a -> Identity a)
-> (InsOrdHashMap k v -> InsOrdHashMap k v) -> a -> a
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
forall k v.
(Eq k, Hashable k) =>
k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
InsOrdHashMap.insert (v -> k
f v
dfn) v
dfn) a
st t (Index a, v)
xs
mkPermDefs :: d
-> [(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, PermDef b perm)]
mkPermDefs d
pt = ((SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)
-> m (QualifiedObject a, PermDef b perm))
-> [(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, PermDef b perm)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)
-> m (QualifiedObject a, PermDef b perm)
forall {m :: * -> *} {b :: BackendType} {perm :: BackendType -> *}
{a} {d}.
(FromJSON (PermDefPermission b perm), MonadError QErr m) =>
(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)
-> m (QualifiedObject a, PermDef b perm)
permRowToDef ([(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, PermDef b perm)])
-> ([(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)]
-> [(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)])
-> [(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, PermDef b perm)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text) -> Bool)
-> [(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)]
-> [(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)]
forall a. (a -> Bool) -> [a] -> [a]
filter (\(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)
pr -> (SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)
pr (SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)
-> Getting
d (SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text) d
-> d
forall s a. s -> Getting a s a -> a
^. Getting d (SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text) d
forall s t a b. Field4 s t a b => Lens s t a b
Lens
(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)
(SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)
d
d
_4 d -> d -> Bool
forall a. Eq a => a -> a -> Bool
== d
pt)
permRowToDef :: (SchemaName, a, RoleName, d, ViaJSON Value, Maybe Text)
-> m (QualifiedObject a, PermDef b perm)
permRowToDef (SchemaName
sn, a
tn, RoleName
rn, d
_, PG.ViaJSON Value
pDef, Maybe Text
mComment) = do
PermDefPermission b perm
perm <- Value -> m (PermDefPermission b perm)
forall a (m :: * -> *). (FromJSON a, QErrM m) => Value -> m a
decodeValue Value
pDef
(QualifiedObject a, PermDef b perm)
-> m (QualifiedObject a, PermDef b perm)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SchemaName -> a -> QualifiedObject a
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
sn a
tn, RoleName
-> PermDefPermission b perm -> Maybe Text -> PermDef b perm
forall (b :: BackendType) (perm :: BackendType -> *).
RoleName
-> PermDefPermission b perm -> Maybe Text -> PermDef b perm
PermDef RoleName
rn PermDefPermission b perm
perm Maybe Text
mComment)
mkRelDefs :: d
-> [(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, RelDef a)]
mkRelDefs d
rt = ((SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)
-> m (QualifiedObject a, RelDef a))
-> [(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, RelDef a)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)
-> m (QualifiedObject a, RelDef a)
forall {m :: * -> *} {a} {a} {d}.
(FromJSON a, MonadError QErr m) =>
(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)
-> m (QualifiedObject a, RelDef a)
relRowToDef ([(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, RelDef a)])
-> ([(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)]
-> [(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)])
-> [(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)]
-> m [(QualifiedObject a, RelDef a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((SchemaName, a, RelName, d, ViaJSON Value, Maybe Text) -> Bool)
-> [(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)]
-> [(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)]
forall a. (a -> Bool) -> [a] -> [a]
filter (\(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)
rr -> (SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)
rr (SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)
-> Getting
d (SchemaName, a, RelName, d, ViaJSON Value, Maybe Text) d
-> d
forall s a. s -> Getting a s a -> a
^. Getting d (SchemaName, a, RelName, d, ViaJSON Value, Maybe Text) d
forall s t a b. Field4 s t a b => Lens s t a b
Lens
(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)
(SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)
d
d
_4 d -> d -> Bool
forall a. Eq a => a -> a -> Bool
== d
rt)
relRowToDef :: (SchemaName, a, RelName, d, ViaJSON Value, Maybe Text)
-> m (QualifiedObject a, RelDef a)
relRowToDef (SchemaName
sn, a
tn, RelName
rn, d
_, PG.ViaJSON Value
rDef, Maybe Text
mComment) = do
a
using <- Value -> m a
forall a (m :: * -> *). (FromJSON a, QErrM m) => Value -> m a
decodeValue Value
rDef
(QualifiedObject a, RelDef a) -> m (QualifiedObject a, RelDef a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SchemaName -> a -> QualifiedObject a
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
sn a
tn, RelName -> a -> Maybe Text -> RelDef a
forall a. RelName -> a -> Maybe Text -> RelDef a
RelDef RelName
rn a
using Maybe Text
mComment)
mkTriggerMetaDefs :: [(SchemaName, a, ViaJSON Value)]
-> TxET
QErr
IO
[(QualifiedObject a, EventTriggerConf ('Postgres 'Vanilla))]
mkTriggerMetaDefs = ((SchemaName, a, ViaJSON Value)
-> TxET
QErr IO (QualifiedObject a, EventTriggerConf ('Postgres 'Vanilla)))
-> [(SchemaName, a, ViaJSON Value)]
-> TxET
QErr
IO
[(QualifiedObject a, EventTriggerConf ('Postgres 'Vanilla))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (SchemaName, a, ViaJSON Value)
-> TxET
QErr IO (QualifiedObject a, EventTriggerConf ('Postgres 'Vanilla))
forall {m :: * -> *} {pgKind :: PostgresKind} {a}.
(HasTag ('Postgres pgKind), Typeable pgKind,
PostgresBackend pgKind,
HasCodec (BackendSourceKind ('Postgres pgKind)), MonadError QErr m,
FromJSON (BackendSourceKind ('Postgres pgKind))) =>
(SchemaName, a, ViaJSON Value)
-> m (QualifiedObject a, EventTriggerConf ('Postgres pgKind))
trigRowToDef
trigRowToDef :: (SchemaName, a, ViaJSON Value)
-> m (QualifiedObject a, EventTriggerConf ('Postgres pgKind))
trigRowToDef (SchemaName
sn, a
tn, PG.ViaJSON Value
configuration) = do
EventTriggerConf ('Postgres pgKind)
conf :: EventTriggerConf ('Postgres pgKind) <- Value -> m (EventTriggerConf ('Postgres pgKind))
forall a (m :: * -> *). (FromJSON a, QErrM m) => Value -> m a
decodeValue Value
configuration
(QualifiedObject a, EventTriggerConf ('Postgres pgKind))
-> m (QualifiedObject a, EventTriggerConf ('Postgres pgKind))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SchemaName -> a -> QualifiedObject a
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
sn a
tn, EventTriggerConf ('Postgres pgKind)
conf)
fetchTables :: TxET
QErr
IO
[(SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))]
fetchTables =
(PGTxErr -> QErr)
-> Query
-> ()
-> Bool
-> TxET
QErr
IO
[(SchemaName, TableName, Bool,
Maybe (ViaJSON (TableConfig ('Postgres 'Vanilla))))]
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
SELECT table_schema, table_name, is_enum, configuration::json
FROM hdb_catalog.hdb_table
WHERE is_system_defined = 'false'
ORDER BY table_schema ASC, table_name ASC
|]
()
Bool
False
fetchRelationships :: TxET
QErr
IO
[(SchemaName, TableName, RelName, RelType, ViaJSON Value,
Maybe Text)]
fetchRelationships =
(PGTxErr -> QErr)
-> Query
-> ()
-> Bool
-> TxET
QErr
IO
[(SchemaName, TableName, RelName, RelType, ViaJSON Value,
Maybe Text)]
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
SELECT table_schema, table_name, rel_name, rel_type, rel_def::json, comment
FROM hdb_catalog.hdb_relationship
WHERE is_system_defined = 'false'
ORDER BY table_schema ASC, table_name ASC, rel_name ASC
|]
()
Bool
False
fetchPermissions :: TxET
QErr
IO
[(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
fetchPermissions =
(PGTxErr -> QErr)
-> Query
-> ()
-> Bool
-> TxET
QErr
IO
[(SchemaName, TableName, RoleName, PermType, ViaJSON Value,
Maybe Text)]
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
SELECT table_schema, table_name, role_name, perm_type, perm_def::json, comment
FROM hdb_catalog.hdb_permission
WHERE is_system_defined = 'false'
ORDER BY table_schema ASC, table_name ASC, role_name ASC, perm_type ASC
|]
()
Bool
False
fetchEventTriggers :: TxET QErr IO [(SchemaName, TableName, ViaJSON Value)]
fetchEventTriggers =
(PGTxErr -> QErr)
-> Query
-> ()
-> Bool
-> TxET QErr IO [(SchemaName, TableName, ViaJSON Value)]
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
SELECT e.schema_name, e.table_name, e.configuration::json
FROM hdb_catalog.event_triggers e
ORDER BY e.schema_name ASC, e.table_name ASC, e.name ASC
|]
()
Bool
False
fetchFunctions :: TxET QErr IO (Functions ('Postgres 'Vanilla))
fetchFunctions = do
[(SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)))]
l <-
(PGTxErr -> QErr)
-> Query
-> ()
-> Bool
-> TxET
QErr
IO
[(SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)))]
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
SELECT function_schema, function_name, configuration::json
FROM hdb_catalog.hdb_function
WHERE is_system_defined = 'false'
ORDER BY function_schema ASC, function_name ASC
|]
()
Bool
False
Functions ('Postgres 'Vanilla)
-> TxET QErr IO (Functions ('Postgres 'Vanilla))
forall a. a -> TxET QErr IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
(Functions ('Postgres 'Vanilla)
-> TxET QErr IO (Functions ('Postgres 'Vanilla)))
-> Functions ('Postgres 'Vanilla)
-> TxET QErr IO (Functions ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ (FunctionMetadata ('Postgres 'Vanilla)
-> FunctionName ('Postgres 'Vanilla))
-> [FunctionMetadata ('Postgres 'Vanilla)]
-> Functions ('Postgres 'Vanilla)
forall k a. Hashable k => (a -> k) -> [a] -> InsOrdHashMap k a
oMapFromL FunctionMetadata ('Postgres 'Vanilla)
-> FunctionName ('Postgres 'Vanilla)
forall (b :: BackendType). FunctionMetadata b -> FunctionName b
_fmFunction
([FunctionMetadata ('Postgres 'Vanilla)]
-> Functions ('Postgres 'Vanilla))
-> [FunctionMetadata ('Postgres 'Vanilla)]
-> Functions ('Postgres 'Vanilla)
forall a b. (a -> b) -> a -> b
$ (((SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)))
-> FunctionMetadata ('Postgres 'Vanilla))
-> [(SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)))]
-> [FunctionMetadata ('Postgres 'Vanilla)])
-> [(SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)))]
-> ((SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)))
-> FunctionMetadata ('Postgres 'Vanilla))
-> [FunctionMetadata ('Postgres 'Vanilla)]
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)))
-> FunctionMetadata ('Postgres 'Vanilla))
-> [(SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)))]
-> [FunctionMetadata ('Postgres 'Vanilla)]
forall a b. (a -> b) -> [a] -> [b]
map [(SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)))]
l
(((SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)))
-> FunctionMetadata ('Postgres 'Vanilla))
-> [FunctionMetadata ('Postgres 'Vanilla)])
-> ((SchemaName, FunctionName,
ViaJSON (FunctionConfig ('Postgres 'Vanilla)))
-> FunctionMetadata ('Postgres 'Vanilla))
-> [FunctionMetadata ('Postgres 'Vanilla)]
forall a b. (a -> b) -> a -> b
$ \(SchemaName
sn, FunctionName
fn, PG.ViaJSON FunctionConfig ('Postgres 'Vanilla)
config) ->
FunctionName ('Postgres 'Vanilla)
-> FunctionConfig ('Postgres 'Vanilla)
-> [FunctionPermissionInfo]
-> Maybe Text
-> FunctionMetadata ('Postgres 'Vanilla)
forall (b :: BackendType).
FunctionName b
-> FunctionConfig b
-> [FunctionPermissionInfo]
-> Maybe Text
-> FunctionMetadata b
FunctionMetadata (SchemaName -> FunctionName -> QualifiedFunction
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
sn FunctionName
fn) FunctionConfig ('Postgres 'Vanilla)
config [] Maybe Text
forall a. Maybe a
Nothing
fetchRemoteSchemas :: TxET QErr IO [RemoteSchemaMetadataG r]
fetchRemoteSchemas =
((RemoteSchemaName, ViaJSON RemoteSchemaDef, Maybe Text)
-> RemoteSchemaMetadataG r)
-> [(RemoteSchemaName, ViaJSON RemoteSchemaDef, Maybe Text)]
-> [RemoteSchemaMetadataG r]
forall a b. (a -> b) -> [a] -> [b]
map (RemoteSchemaName, ViaJSON RemoteSchemaDef, Maybe Text)
-> RemoteSchemaMetadataG r
forall {r}.
(RemoteSchemaName, ViaJSON RemoteSchemaDef, Maybe Text)
-> RemoteSchemaMetadataG r
fromRow
([(RemoteSchemaName, ViaJSON RemoteSchemaDef, Maybe Text)]
-> [RemoteSchemaMetadataG r])
-> TxET
QErr IO [(RemoteSchemaName, ViaJSON RemoteSchemaDef, Maybe Text)]
-> TxET QErr IO [RemoteSchemaMetadataG r]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PGTxErr -> QErr)
-> Query
-> ()
-> Bool
-> TxET
QErr IO [(RemoteSchemaName, ViaJSON RemoteSchemaDef, Maybe Text)]
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
SELECT name, definition, comment
FROM hdb_catalog.remote_schemas
ORDER BY name ASC
|]
()
Bool
True
where
fromRow :: (RemoteSchemaName, ViaJSON RemoteSchemaDef, Maybe Text)
-> RemoteSchemaMetadataG r
fromRow (RemoteSchemaName
name, PG.ViaJSON RemoteSchemaDef
def, Maybe Text
comment) =
RemoteSchemaName
-> RemoteSchemaDef
-> Maybe Text
-> [RemoteSchemaPermissionMetadata]
-> SchemaRemoteRelationships r
-> RemoteSchemaMetadataG r
forall r.
RemoteSchemaName
-> RemoteSchemaDef
-> Maybe Text
-> [RemoteSchemaPermissionMetadata]
-> SchemaRemoteRelationships r
-> RemoteSchemaMetadataG r
RemoteSchemaMetadata RemoteSchemaName
name RemoteSchemaDef
def Maybe Text
comment [RemoteSchemaPermissionMetadata]
forall a. Monoid a => a
mempty SchemaRemoteRelationships r
forall a. Monoid a => a
mempty
fetchCollections :: TxET QErr IO [CreateCollection]
fetchCollections =
((CollectionName, ViaJSON CollectionDef, Maybe Text)
-> CreateCollection)
-> [(CollectionName, ViaJSON CollectionDef, Maybe Text)]
-> [CreateCollection]
forall a b. (a -> b) -> [a] -> [b]
map (CollectionName, ViaJSON CollectionDef, Maybe Text)
-> CreateCollection
fromRow
([(CollectionName, ViaJSON CollectionDef, Maybe Text)]
-> [CreateCollection])
-> TxET
QErr IO [(CollectionName, ViaJSON CollectionDef, Maybe Text)]
-> TxET QErr IO [CreateCollection]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PGTxErr -> QErr)
-> Query
-> ()
-> Bool
-> TxET
QErr IO [(CollectionName, ViaJSON CollectionDef, Maybe Text)]
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
SELECT collection_name, collection_defn::json, comment
FROM hdb_catalog.hdb_query_collection
WHERE is_system_defined = 'false'
ORDER BY collection_name ASC
|]
()
Bool
False
where
fromRow :: (CollectionName, ViaJSON CollectionDef, Maybe Text)
-> CreateCollection
fromRow (CollectionName
name, PG.ViaJSON CollectionDef
defn, Maybe Text
mComment) =
CollectionName -> CollectionDef -> Maybe Text -> CreateCollection
CreateCollection CollectionName
name CollectionDef
defn Maybe Text
mComment
fetchAllowlist :: TxET QErr IO [AllowlistEntry]
fetchAllowlist =
(Identity CollectionName -> AllowlistEntry)
-> [Identity CollectionName] -> [AllowlistEntry]
forall a b. (a -> b) -> [a] -> [b]
map Identity CollectionName -> AllowlistEntry
fromRow
([Identity CollectionName] -> [AllowlistEntry])
-> TxET QErr IO [Identity CollectionName]
-> TxET QErr IO [AllowlistEntry]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PGTxErr -> QErr)
-> Query -> () -> Bool -> TxET QErr IO [Identity CollectionName]
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
SELECT collection_name
FROM hdb_catalog.hdb_allowlist
ORDER BY collection_name ASC
|]
()
Bool
False
where
fromRow :: Identity CollectionName -> AllowlistEntry
fromRow (Identity CollectionName
name) = CollectionName -> AllowlistScope -> AllowlistEntry
AllowlistEntry CollectionName
name AllowlistScope
AllowlistScopeGlobal
fetchComputedFields :: TxET
QErr
IO
[(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
fetchComputedFields = do
[(SchemaName, TableName, ComputedFieldName,
ViaJSON (ComputedFieldDefinition ('Postgres 'Vanilla)),
Maybe Text)]
r <-
(PGTxErr -> QErr)
-> Query
-> ()
-> Bool
-> TxET
QErr
IO
[(SchemaName, TableName, ComputedFieldName,
ViaJSON (ComputedFieldDefinition ('Postgres 'Vanilla)),
Maybe Text)]
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
SELECT table_schema, table_name, computed_field_name,
definition::json, comment
FROM hdb_catalog.hdb_computed_field
|]
()
Bool
False
[(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
-> TxET
QErr
IO
[(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
forall a. a -> TxET QErr IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
([(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
-> TxET
QErr
IO
[(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))])
-> [(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
-> TxET
QErr
IO
[(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
forall a b. (a -> b) -> a -> b
$ (((SchemaName, TableName, ComputedFieldName,
ViaJSON (ComputedFieldDefinition ('Postgres 'Vanilla)), Maybe Text)
-> (QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla)))
-> [(SchemaName, TableName, ComputedFieldName,
ViaJSON (ComputedFieldDefinition ('Postgres 'Vanilla)),
Maybe Text)]
-> [(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))])
-> [(SchemaName, TableName, ComputedFieldName,
ViaJSON (ComputedFieldDefinition ('Postgres 'Vanilla)),
Maybe Text)]
-> ((SchemaName, TableName, ComputedFieldName,
ViaJSON (ComputedFieldDefinition ('Postgres 'Vanilla)), Maybe Text)
-> (QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla)))
-> [(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((SchemaName, TableName, ComputedFieldName,
ViaJSON (ComputedFieldDefinition ('Postgres 'Vanilla)), Maybe Text)
-> (QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla)))
-> [(SchemaName, TableName, ComputedFieldName,
ViaJSON (ComputedFieldDefinition ('Postgres 'Vanilla)),
Maybe Text)]
-> [(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
forall a b. (a -> b) -> [a] -> [b]
map [(SchemaName, TableName, ComputedFieldName,
ViaJSON (ComputedFieldDefinition ('Postgres 'Vanilla)),
Maybe Text)]
r
(((SchemaName, TableName, ComputedFieldName,
ViaJSON (ComputedFieldDefinition ('Postgres 'Vanilla)), Maybe Text)
-> (QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla)))
-> [(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))])
-> ((SchemaName, TableName, ComputedFieldName,
ViaJSON (ComputedFieldDefinition ('Postgres 'Vanilla)), Maybe Text)
-> (QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla)))
-> [(QualifiedTable, ComputedFieldMetadata ('Postgres 'Vanilla))]
forall a b. (a -> b) -> a -> b
$ \(SchemaName
schema, TableName
table, ComputedFieldName
name, PG.ViaJSON ComputedFieldDefinition ('Postgres 'Vanilla)
definition, Maybe Text
comment) ->
( SchemaName -> TableName -> QualifiedTable
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
schema TableName
table,
ComputedFieldName
-> ComputedFieldDefinition ('Postgres 'Vanilla)
-> Comment
-> ComputedFieldMetadata ('Postgres 'Vanilla)
forall (b :: BackendType).
ComputedFieldName
-> ComputedFieldDefinition b -> Comment -> ComputedFieldMetadata b
ComputedFieldMetadata ComputedFieldName
name ComputedFieldDefinition ('Postgres 'Vanilla)
definition (Maybe Text -> Comment
commentFromMaybeText Maybe Text
comment)
)
fetchCronTriggers :: TxET QErr IO CronTriggers
fetchCronTriggers =
(CronTriggerMetadata -> TriggerName)
-> [CronTriggerMetadata] -> CronTriggers
forall k a. Hashable k => (a -> k) -> [a] -> InsOrdHashMap k a
oMapFromL CronTriggerMetadata -> TriggerName
ctName
([CronTriggerMetadata] -> CronTriggers)
-> ([(TriggerName, ViaJSON InputWebhook, CronSchedule,
Maybe (ViaJSON Value), ViaJSON STRetryConf, ViaJSON [HeaderConf],
Bool, Maybe Text)]
-> [CronTriggerMetadata])
-> [(TriggerName, ViaJSON InputWebhook, CronSchedule,
Maybe (ViaJSON Value), ViaJSON STRetryConf, ViaJSON [HeaderConf],
Bool, Maybe Text)]
-> CronTriggers
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((TriggerName, ViaJSON InputWebhook, CronSchedule,
Maybe (ViaJSON Value), ViaJSON STRetryConf, ViaJSON [HeaderConf],
Bool, Maybe Text)
-> CronTriggerMetadata)
-> [(TriggerName, ViaJSON InputWebhook, CronSchedule,
Maybe (ViaJSON Value), ViaJSON STRetryConf, ViaJSON [HeaderConf],
Bool, Maybe Text)]
-> [CronTriggerMetadata]
forall a b. (a -> b) -> [a] -> [b]
map (TriggerName, ViaJSON InputWebhook, CronSchedule,
Maybe (ViaJSON Value), ViaJSON STRetryConf, ViaJSON [HeaderConf],
Bool, Maybe Text)
-> CronTriggerMetadata
uncurryCronTrigger
([(TriggerName, ViaJSON InputWebhook, CronSchedule,
Maybe (ViaJSON Value), ViaJSON STRetryConf, ViaJSON [HeaderConf],
Bool, Maybe Text)]
-> CronTriggers)
-> TxET
QErr
IO
[(TriggerName, ViaJSON InputWebhook, CronSchedule,
Maybe (ViaJSON Value), ViaJSON STRetryConf, ViaJSON [HeaderConf],
Bool, Maybe Text)]
-> TxET QErr IO CronTriggers
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PGTxErr -> QErr)
-> Query
-> ()
-> Bool
-> TxET
QErr
IO
[(TriggerName, ViaJSON InputWebhook, CronSchedule,
Maybe (ViaJSON Value), ViaJSON STRetryConf, ViaJSON [HeaderConf],
Bool, Maybe Text)]
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
SELECT ct.name, ct.webhook_conf, ct.cron_schedule, ct.payload,
ct.retry_conf, ct.header_conf, ct.include_in_metadata, ct.comment
FROM hdb_catalog.hdb_cron_triggers ct
WHERE include_in_metadata
|]
()
Bool
False
where
uncurryCronTrigger :: (TriggerName, ViaJSON InputWebhook, CronSchedule,
Maybe (ViaJSON Value), ViaJSON STRetryConf, ViaJSON [HeaderConf],
Bool, Maybe Text)
-> CronTriggerMetadata
uncurryCronTrigger
(TriggerName
name, ViaJSON InputWebhook
webhook, CronSchedule
schedule, Maybe (ViaJSON Value)
payload, ViaJSON STRetryConf
retryConfig, ViaJSON [HeaderConf]
headerConfig, Bool
includeMetadata, Maybe Text
comment) =
CronTriggerMetadata
{ ctName :: TriggerName
ctName = TriggerName
name,
ctWebhook :: InputWebhook
ctWebhook = ViaJSON InputWebhook -> InputWebhook
forall a. ViaJSON a -> a
PG.getViaJSON ViaJSON InputWebhook
webhook,
ctSchedule :: CronSchedule
ctSchedule = CronSchedule
schedule,
ctPayload :: Maybe Value
ctPayload = ViaJSON Value -> Value
forall a. ViaJSON a -> a
PG.getViaJSON (ViaJSON Value -> Value) -> Maybe (ViaJSON Value) -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (ViaJSON Value)
payload,
ctRetryConf :: STRetryConf
ctRetryConf = ViaJSON STRetryConf -> STRetryConf
forall a. ViaJSON a -> a
PG.getViaJSON ViaJSON STRetryConf
retryConfig,
ctHeaders :: [HeaderConf]
ctHeaders = ViaJSON [HeaderConf] -> [HeaderConf]
forall a. ViaJSON a -> a
PG.getViaJSON ViaJSON [HeaderConf]
headerConfig,
ctIncludeInMetadata :: Bool
ctIncludeInMetadata = Bool
includeMetadata,
ctComment :: Maybe Text
ctComment = Maybe Text
comment,
ctRequestTransform :: Maybe RequestTransform
ctRequestTransform = Maybe RequestTransform
forall a. Maybe a
Nothing,
ctResponseTransform :: Maybe MetadataResponseTransform
ctResponseTransform = Maybe MetadataResponseTransform
forall a. Maybe a
Nothing
}
fetchCustomTypes :: PG.TxE QErr CustomTypes
fetchCustomTypes :: TxE QErr CustomTypes
fetchCustomTypes =
ViaJSON CustomTypes -> CustomTypes
forall a. ViaJSON a -> a
PG.getViaJSON
(ViaJSON CustomTypes -> CustomTypes)
-> (SingleRow (Identity (ViaJSON CustomTypes))
-> ViaJSON CustomTypes)
-> SingleRow (Identity (ViaJSON CustomTypes))
-> CustomTypes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identity (ViaJSON CustomTypes) -> ViaJSON CustomTypes
forall a. Identity a -> a
runIdentity
(Identity (ViaJSON CustomTypes) -> ViaJSON CustomTypes)
-> (SingleRow (Identity (ViaJSON CustomTypes))
-> Identity (ViaJSON CustomTypes))
-> SingleRow (Identity (ViaJSON CustomTypes))
-> ViaJSON CustomTypes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SingleRow (Identity (ViaJSON CustomTypes))
-> Identity (ViaJSON CustomTypes)
forall a. SingleRow a -> a
PG.getRow
(SingleRow (Identity (ViaJSON CustomTypes)) -> CustomTypes)
-> TxET QErr IO (SingleRow (Identity (ViaJSON CustomTypes)))
-> TxE QErr CustomTypes
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PGTxErr -> QErr)
-> Query
-> [PrepArg]
-> Bool
-> TxET QErr IO (SingleRow (Identity (ViaJSON CustomTypes)))
forall (m :: * -> *) a e.
(MonadIO m, FromRes a) =>
(PGTxErr -> e) -> Query -> [PrepArg] -> Bool -> TxET e m a
PG.rawQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
select coalesce((select custom_types::json from hdb_catalog.hdb_custom_types), '{}'::json)
|]
[]
Bool
False
fetchActions :: TxET QErr IO [ActionMetadata]
fetchActions =
ViaJSON [ActionMetadata] -> [ActionMetadata]
forall a. ViaJSON a -> a
PG.getViaJSON
(ViaJSON [ActionMetadata] -> [ActionMetadata])
-> (SingleRow (Identity (ViaJSON [ActionMetadata]))
-> ViaJSON [ActionMetadata])
-> SingleRow (Identity (ViaJSON [ActionMetadata]))
-> [ActionMetadata]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identity (ViaJSON [ActionMetadata]) -> ViaJSON [ActionMetadata]
forall a. Identity a -> a
runIdentity
(Identity (ViaJSON [ActionMetadata]) -> ViaJSON [ActionMetadata])
-> (SingleRow (Identity (ViaJSON [ActionMetadata]))
-> Identity (ViaJSON [ActionMetadata]))
-> SingleRow (Identity (ViaJSON [ActionMetadata]))
-> ViaJSON [ActionMetadata]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SingleRow (Identity (ViaJSON [ActionMetadata]))
-> Identity (ViaJSON [ActionMetadata])
forall a. SingleRow a -> a
PG.getRow
(SingleRow (Identity (ViaJSON [ActionMetadata]))
-> [ActionMetadata])
-> TxET QErr IO (SingleRow (Identity (ViaJSON [ActionMetadata])))
-> TxET QErr IO [ActionMetadata]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PGTxErr -> QErr)
-> Query
-> [PrepArg]
-> Bool
-> TxET QErr IO (SingleRow (Identity (ViaJSON [ActionMetadata])))
forall (m :: * -> *) a e.
(MonadIO m, FromRes a) =>
(PGTxErr -> e) -> Query -> [PrepArg] -> Bool -> TxET e m a
PG.rawQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
select
coalesce(
json_agg(
json_build_object(
'name', a.action_name,
'definition', a.action_defn,
'comment', a.comment,
'permissions', ap.permissions
) order by a.action_name asc
),
'[]'
)
from
hdb_catalog.hdb_action as a
left outer join lateral (
select
coalesce(
json_agg(
json_build_object(
'role', ap.role_name,
'comment', ap.comment
) order by ap.role_name asc
),
'[]'
) as permissions
from
hdb_catalog.hdb_action_permission ap
where
ap.action_name = a.action_name
) ap on true;
|]
[]
Bool
False
fetchRemoteRelationships :: TxET QErr IO [(QualifiedTable, RelName, Value)]
fetchRemoteRelationships = do
[(SchemaName, TableName, RelName, ViaJSON Value)]
r <-
(PGTxErr -> QErr)
-> Query
-> ()
-> Bool
-> TxET QErr IO [(SchemaName, TableName, RelName, ViaJSON Value)]
forall (m :: * -> *) a r e.
(MonadIO m, FromRes a, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m a
PG.withQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
SELECT table_schema, table_name,
remote_relationship_name, definition::json
FROM hdb_catalog.hdb_remote_relationship
|]
()
Bool
False
[(QualifiedTable, RelName, Value)]
-> TxET QErr IO [(QualifiedTable, RelName, Value)]
forall a. a -> TxET QErr IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
([(QualifiedTable, RelName, Value)]
-> TxET QErr IO [(QualifiedTable, RelName, Value)])
-> [(QualifiedTable, RelName, Value)]
-> TxET QErr IO [(QualifiedTable, RelName, Value)]
forall a b. (a -> b) -> a -> b
$ (((SchemaName, TableName, RelName, ViaJSON Value)
-> (QualifiedTable, RelName, Value))
-> [(SchemaName, TableName, RelName, ViaJSON Value)]
-> [(QualifiedTable, RelName, Value)])
-> [(SchemaName, TableName, RelName, ViaJSON Value)]
-> ((SchemaName, TableName, RelName, ViaJSON Value)
-> (QualifiedTable, RelName, Value))
-> [(QualifiedTable, RelName, Value)]
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((SchemaName, TableName, RelName, ViaJSON Value)
-> (QualifiedTable, RelName, Value))
-> [(SchemaName, TableName, RelName, ViaJSON Value)]
-> [(QualifiedTable, RelName, Value)]
forall a b. (a -> b) -> [a] -> [b]
map [(SchemaName, TableName, RelName, ViaJSON Value)]
r
(((SchemaName, TableName, RelName, ViaJSON Value)
-> (QualifiedTable, RelName, Value))
-> [(QualifiedTable, RelName, Value)])
-> ((SchemaName, TableName, RelName, ViaJSON Value)
-> (QualifiedTable, RelName, Value))
-> [(QualifiedTable, RelName, Value)]
forall a b. (a -> b) -> a -> b
$ \(SchemaName
schema, TableName
table, RelName
name, PG.ViaJSON Value
definition) ->
( SchemaName -> TableName -> QualifiedTable
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
schema TableName
table,
RelName
name,
Value
definition
)
addCronTriggerForeignKeyConstraint :: (MonadTx m) => m ()
addCronTriggerForeignKeyConstraint :: forall (m :: * -> *). MonadTx m => m ()
addCronTriggerForeignKeyConstraint =
TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx
(TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr) -> Query -> () -> Bool -> TxE QErr ()
forall (m :: * -> *) r e.
(MonadIO m, ToPrepArgs r) =>
(PGTxErr -> e) -> Query -> r -> Bool -> TxET e m ()
PG.unitQE
PGTxErr -> QErr
defaultTxErrorHandler
[PG.sql|
ALTER TABLE hdb_catalog.hdb_cron_events ADD CONSTRAINT
hdb_cron_events_trigger_name_fkey FOREIGN KEY (trigger_name)
REFERENCES hdb_catalog.hdb_cron_triggers(name)
ON UPDATE CASCADE ON DELETE CASCADE;
|]
()
Bool
False
recreateSystemMetadata :: (MonadTx m) => m ()
recreateSystemMetadata :: forall (m :: * -> *). MonadTx m => m ()
recreateSystemMetadata = do
() <- TxE QErr () -> m ()
forall a. TxE QErr a -> m a
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> m a
liftTx (TxE QErr () -> m ()) -> TxE QErr () -> m ()
forall a b. (a -> b) -> a -> b
$ (PGTxErr -> QErr) -> Query -> TxE QErr ()
forall (m :: * -> *) a e.
(MonadIO m, FromRes a) =>
(PGTxErr -> e) -> Query -> TxET e m a
PG.multiQE PGTxErr -> QErr
defaultTxErrorHandler $(makeRelativeToProject "src-rsr/clear_system_metadata.sql" >>= PG.sqlFromFile)
(ReaderT SystemDefined m () -> SystemDefined -> m ())
-> SystemDefined -> ReaderT SystemDefined m () -> m ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip ReaderT SystemDefined m () -> SystemDefined -> m ()
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (Bool -> SystemDefined
SystemDefined Bool
True) (ReaderT SystemDefined m () -> m ())
-> ReaderT SystemDefined m () -> m ()
forall a b. (a -> b) -> a -> b
$ [(QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla))
(ArrRelDef ('Postgres 'Vanilla))])]
-> ((QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
-> ReaderT SystemDefined m ())
-> ReaderT SystemDefined m ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
t a -> (a -> f b) -> f ()
for_ [(QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla))
(ArrRelDef ('Postgres 'Vanilla))])]
systemMetadata \(QualifiedTable
tableName, [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
tableRels) -> do
QualifiedTable
-> Bool
-> TableConfig ('Postgres 'Vanilla)
-> ReaderT SystemDefined m ()
forall (m :: * -> *).
(MonadTx m, MonadReader SystemDefined m) =>
QualifiedTable -> Bool -> TableConfig ('Postgres 'Vanilla) -> m ()
saveTableToCatalog QualifiedTable
tableName Bool
False TableConfig ('Postgres 'Vanilla)
forall (b :: BackendType). TableConfig b
emptyTableConfig
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
-> ReaderT SystemDefined m ())
-> ReaderT SystemDefined m ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
t a -> (a -> f b) -> f ()
for_ [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
tableRels \case
Left ObjRelDef ('Postgres 'Vanilla)
relDef -> QualifiedTable
-> RelType
-> ObjRelDef ('Postgres 'Vanilla)
-> ReaderT SystemDefined m ()
forall (m :: * -> *) a.
(MonadTx m, MonadReader SystemDefined m, ToJSON a) =>
QualifiedTable -> RelType -> RelDef a -> m ()
insertRelationshipToCatalog QualifiedTable
tableName RelType
ObjRel ObjRelDef ('Postgres 'Vanilla)
relDef
Right ArrRelDef ('Postgres 'Vanilla)
relDef -> QualifiedTable
-> RelType
-> ArrRelDef ('Postgres 'Vanilla)
-> ReaderT SystemDefined m ()
forall (m :: * -> *) a.
(MonadTx m, MonadReader SystemDefined m, ToJSON a) =>
QualifiedTable -> RelType -> RelDef a -> m ()
insertRelationshipToCatalog QualifiedTable
tableName RelType
ArrRel ArrRelDef ('Postgres 'Vanilla)
relDef
where
systemMetadata :: [(QualifiedTable, [Either (ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])]
systemMetadata :: [(QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla))
(ArrRelDef ('Postgres 'Vanilla))])]
systemMetadata =
[ SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"information_schema" TableName
"tables" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"information_schema" TableName
"schemata" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"information_schema" TableName
"views" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"information_schema" TableName
"columns" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"hdb_table"
[ NonEmptyText
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {b}. NonEmptyText -> a -> Either (RelDef a) b
objectRel $$(nonEmptyText "detail")
(ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ObjRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
"information_schema" TableName
"tables" [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
[(PGCol, PGCol)]
tableNameMapping,
NonEmptyText
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {b}. NonEmptyText -> a -> Either (RelDef a) b
objectRel $$(nonEmptyText "primary_key")
(ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ObjRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
"hdb_catalog" TableName
"hdb_primary_key" [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
[(PGCol, PGCol)]
tableNameMapping,
NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "columns")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ArrRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
"information_schema" TableName
"columns" [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
[(PGCol, PGCol)]
tableNameMapping,
NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "foreign_key_constraints")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ArrRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
"hdb_catalog" TableName
"hdb_foreign_key_constraint" [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
[(PGCol, PGCol)]
tableNameMapping,
NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "relationships")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ArrRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
"hdb_catalog" TableName
"hdb_relationship" [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
[(PGCol, PGCol)]
tableNameMapping,
NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "permissions")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ArrRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
"hdb_catalog" TableName
"hdb_permission_agg" [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
[(PGCol, PGCol)]
tableNameMapping,
NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "computed_fields")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ArrRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
"hdb_catalog" TableName
"hdb_computed_field" [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
[(PGCol, PGCol)]
tableNameMapping,
NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "check_constraints")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ArrRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
"hdb_catalog" TableName
"hdb_check_constraint" [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
[(PGCol, PGCol)]
tableNameMapping,
NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "unique_constraints")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ArrRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
"hdb_catalog" TableName
"hdb_unique_constraint" [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
[(PGCol, PGCol)]
tableNameMapping
],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_primary_key" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_foreign_key_constraint" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_relationship" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_permission_agg" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_computed_field" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_check_constraint" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_unique_constraint" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_remote_relationship" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"event_triggers"
[ NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "events")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ArrRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
"hdb_catalog" TableName
"event_log" [(Column ('Postgres 'Vanilla)
PGCol
"name", Column ('Postgres 'Vanilla)
PGCol
"trigger_name")]
],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"event_log"
[ NonEmptyText
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {b}. NonEmptyText -> a -> Either (RelDef a) b
objectRel $$(nonEmptyText "trigger")
(ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ObjRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
"hdb_catalog" TableName
"event_triggers" [(Column ('Postgres 'Vanilla)
PGCol
"trigger_name", Column ('Postgres 'Vanilla)
PGCol
"name")],
NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "logs")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla)
forall (b :: BackendType) a. a -> RelUsing b a
RUFKeyOn
(ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla))
-> ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla)
forall a b. (a -> b) -> a -> b
$ TableName ('Postgres 'Vanilla)
-> NonEmpty (Column ('Postgres 'Vanilla))
-> ArrRelUsingFKeyOn ('Postgres 'Vanilla)
forall (b :: BackendType).
TableName b -> NonEmpty (Column b) -> ArrRelUsingFKeyOn b
ArrRelUsingFKeyOn (SchemaName -> TableName -> QualifiedTable
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
"hdb_catalog" TableName
"event_invocation_logs") (PGCol -> NonEmpty PGCol
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PGCol
"event_id")
],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"event_invocation_logs"
[NonEmptyText
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {b}. NonEmptyText -> a -> Either (RelDef a) b
objectRel $$(nonEmptyText "event") (ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla)
forall (b :: BackendType) a. a -> RelUsing b a
RUFKeyOn (ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla))
-> ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla)
forall a b. (a -> b) -> a -> b
$ NonEmpty (Column ('Postgres 'Vanilla))
-> ObjRelUsingChoice ('Postgres 'Vanilla)
forall (b :: BackendType).
NonEmpty (Column b) -> ObjRelUsingChoice b
SameTable (PGCol -> NonEmpty PGCol
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PGCol
"event_id")],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_function" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"hdb_function_agg"
[ NonEmptyText
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {b}. NonEmptyText -> a -> Either (RelDef a) b
objectRel $$(nonEmptyText "return_table_info")
(ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ObjRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig
SchemaName
"hdb_catalog"
TableName
"hdb_table"
[ (Column ('Postgres 'Vanilla)
PGCol
"return_type_schema", Column ('Postgres 'Vanilla)
PGCol
"table_schema"),
(Column ('Postgres 'Vanilla)
PGCol
"return_type_name", Column ('Postgres 'Vanilla)
PGCol
"table_name")
]
],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"remote_schemas" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_version" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_query_collection" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_allowlist" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_custom_types" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_action_permission" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"hdb_action"
[ NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "permissions")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ArrRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig
SchemaName
"hdb_catalog"
TableName
"hdb_action_permission"
[(Column ('Postgres 'Vanilla)
PGCol
"action_name", Column ('Postgres 'Vanilla)
PGCol
"action_name")]
],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
"hdb_catalog" TableName
"hdb_action_log" [],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"hdb_role"
[ NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "action_permissions")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ArrRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig
SchemaName
"hdb_catalog"
TableName
"hdb_action_permission"
[(Column ('Postgres 'Vanilla)
PGCol
"role_name", Column ('Postgres 'Vanilla)
PGCol
"role_name")],
NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "permissions")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ SchemaName
-> TableName
-> [(Column ('Postgres 'Vanilla), Column ('Postgres 'Vanilla))]
-> ArrRelUsing ('Postgres 'Vanilla)
forall {b :: BackendType} {a} {a}.
(TableName b ~ QualifiedObject a, Hashable (Column b)) =>
SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig
SchemaName
"hdb_catalog"
TableName
"hdb_permission_agg"
[(Column ('Postgres 'Vanilla)
PGCol
"role_name", Column ('Postgres 'Vanilla)
PGCol
"role_name")]
],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"hdb_cron_triggers"
[ NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "cron_events")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla)
forall (b :: BackendType) a. a -> RelUsing b a
RUFKeyOn
(ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla))
-> ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla)
forall a b. (a -> b) -> a -> b
$ TableName ('Postgres 'Vanilla)
-> NonEmpty (Column ('Postgres 'Vanilla))
-> ArrRelUsingFKeyOn ('Postgres 'Vanilla)
forall (b :: BackendType).
TableName b -> NonEmpty (Column b) -> ArrRelUsingFKeyOn b
ArrRelUsingFKeyOn (SchemaName -> TableName -> QualifiedTable
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
"hdb_catalog" TableName
"hdb_cron_events") (PGCol -> NonEmpty PGCol
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PGCol
"trigger_name")
],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"hdb_cron_events"
[ NonEmptyText
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {b}. NonEmptyText -> a -> Either (RelDef a) b
objectRel $$(nonEmptyText "cron_trigger") (ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla)
forall (b :: BackendType) a. a -> RelUsing b a
RUFKeyOn (ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla))
-> ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla)
forall a b. (a -> b) -> a -> b
$ NonEmpty (Column ('Postgres 'Vanilla))
-> ObjRelUsingChoice ('Postgres 'Vanilla)
forall (b :: BackendType).
NonEmpty (Column b) -> ObjRelUsingChoice b
SameTable (PGCol -> NonEmpty PGCol
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PGCol
"trigger_name"),
NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "cron_event_logs")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla)
forall (b :: BackendType) a. a -> RelUsing b a
RUFKeyOn
(ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla))
-> ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla)
forall a b. (a -> b) -> a -> b
$ TableName ('Postgres 'Vanilla)
-> NonEmpty (Column ('Postgres 'Vanilla))
-> ArrRelUsingFKeyOn ('Postgres 'Vanilla)
forall (b :: BackendType).
TableName b -> NonEmpty (Column b) -> ArrRelUsingFKeyOn b
ArrRelUsingFKeyOn (SchemaName -> TableName -> QualifiedTable
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
"hdb_catalog" TableName
"hdb_cron_event_invocation_logs") (PGCol -> NonEmpty PGCol
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PGCol
"event_id")
],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"hdb_cron_event_invocation_logs"
[ NonEmptyText
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {b}. NonEmptyText -> a -> Either (RelDef a) b
objectRel $$(nonEmptyText "cron_event") (ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla)
forall (b :: BackendType) a. a -> RelUsing b a
RUFKeyOn (ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla))
-> ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla)
forall a b. (a -> b) -> a -> b
$ NonEmpty (Column ('Postgres 'Vanilla))
-> ObjRelUsingChoice ('Postgres 'Vanilla)
forall (b :: BackendType).
NonEmpty (Column b) -> ObjRelUsingChoice b
SameTable (PGCol -> NonEmpty PGCol
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PGCol
"event_id")
],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"hdb_scheduled_events"
[ NonEmptyText
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {a}. NonEmptyText -> a -> Either a (RelDef a)
arrayRel $$(nonEmptyText "scheduled_event_logs")
(ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ArrRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla)
forall (b :: BackendType) a. a -> RelUsing b a
RUFKeyOn
(ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla))
-> ArrRelUsingFKeyOn ('Postgres 'Vanilla)
-> ArrRelUsing ('Postgres 'Vanilla)
forall a b. (a -> b) -> a -> b
$ TableName ('Postgres 'Vanilla)
-> NonEmpty (Column ('Postgres 'Vanilla))
-> ArrRelUsingFKeyOn ('Postgres 'Vanilla)
forall (b :: BackendType).
TableName b -> NonEmpty (Column b) -> ArrRelUsingFKeyOn b
ArrRelUsingFKeyOn (SchemaName -> TableName -> QualifiedTable
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
"hdb_catalog" TableName
"hdb_scheduled_event_invocation_logs") (PGCol -> NonEmpty PGCol
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PGCol
"event_id")
],
SchemaName
-> TableName
-> [Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))]
-> (QualifiedTable,
[Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])
forall {a} {b}. SchemaName -> a -> b -> (QualifiedObject a, b)
table
SchemaName
"hdb_catalog"
TableName
"hdb_scheduled_event_invocation_logs"
[ NonEmptyText
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall {a} {b}. NonEmptyText -> a -> Either (RelDef a) b
objectRel $$(nonEmptyText "scheduled_event") (ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla)))
-> ObjRelUsing ('Postgres 'Vanilla)
-> Either
(ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))
forall a b. (a -> b) -> a -> b
$ ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla)
forall (b :: BackendType) a. a -> RelUsing b a
RUFKeyOn (ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla))
-> ObjRelUsingChoice ('Postgres 'Vanilla)
-> ObjRelUsing ('Postgres 'Vanilla)
forall a b. (a -> b) -> a -> b
$ NonEmpty (Column ('Postgres 'Vanilla))
-> ObjRelUsingChoice ('Postgres 'Vanilla)
forall (b :: BackendType).
NonEmpty (Column b) -> ObjRelUsingChoice b
SameTable (PGCol -> NonEmpty PGCol
forall a. a -> NonEmpty a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PGCol
"event_id")
]
]
tableNameMapping :: [(PGCol, PGCol)]
tableNameMapping =
[ (PGCol
"table_schema", PGCol
"table_schema"),
(PGCol
"table_name", PGCol
"table_name")
]
table :: SchemaName -> a -> b -> (QualifiedObject a, b)
table SchemaName
schemaName a
tableName b
relationships = (SchemaName -> a -> QualifiedObject a
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
schemaName a
tableName, b
relationships)
objectRel :: NonEmptyText -> a -> Either (RelDef a) b
objectRel NonEmptyText
name a
using = RelDef a -> Either (RelDef a) b
forall a b. a -> Either a b
Left (RelDef a -> Either (RelDef a) b)
-> RelDef a -> Either (RelDef a) b
forall a b. (a -> b) -> a -> b
$ RelName -> a -> Maybe Text -> RelDef a
forall a. RelName -> a -> Maybe Text -> RelDef a
RelDef (NonEmptyText -> RelName
RelName NonEmptyText
name) a
using Maybe Text
forall a. Maybe a
Nothing
arrayRel :: NonEmptyText -> a -> Either a (RelDef a)
arrayRel NonEmptyText
name a
using = RelDef a -> Either a (RelDef a)
forall a b. b -> Either a b
Right (RelDef a -> Either a (RelDef a))
-> RelDef a -> Either a (RelDef a)
forall a b. (a -> b) -> a -> b
$ RelName -> a -> Maybe Text -> RelDef a
forall a. RelName -> a -> Maybe Text -> RelDef a
RelDef (NonEmptyText -> RelName
RelName NonEmptyText
name) a
using Maybe Text
forall a. Maybe a
Nothing
manualConfig :: SchemaName -> a -> [(Column b, Column b)] -> RelUsing b a
manualConfig SchemaName
schemaName a
tableName [(Column b, Column b)]
columns =
RelManualTableConfig b -> RelUsing b a
forall (b :: BackendType) a. RelManualTableConfig b -> RelUsing b a
RUManual
(RelManualTableConfig b -> RelUsing b a)
-> RelManualTableConfig b -> RelUsing b a
forall a b. (a -> b) -> a -> b
$ TableName b -> RelManualCommon b -> RelManualTableConfig b
forall (b :: BackendType).
TableName b -> RelManualCommon b -> RelManualTableConfig b
RelManualTableConfig
(SchemaName -> a -> QualifiedObject a
forall a. SchemaName -> a -> QualifiedObject a
QualifiedObject SchemaName
schemaName a
tableName)
(HashMap (Column b) (Column b)
-> Maybe InsertOrder -> RelManualCommon b
forall (b :: BackendType).
HashMap (Column b) (Column b)
-> Maybe InsertOrder -> RelManualCommon b
RelManualCommon ([(Column b, Column b)] -> HashMap (Column b) (Column b)
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HashMap.fromList [(Column b, Column b)]
columns) Maybe InsertOrder
forall a. Maybe a
Nothing)