Safe Haskell | None |
---|---|
Language | Haskell2010 |
Funtions related to hdb_catalog
schema prior to metadata separation (catalog version < 43).
Synopsis
- saveMetadataToHdbTables :: (MonadTx m, MonadReader SystemDefined m) => MetadataNoSources -> m ()
- saveTableToCatalog :: (MonadTx m, MonadReader SystemDefined m) => QualifiedTable -> Bool -> TableConfig ('Postgres 'Vanilla) -> m ()
- insertRelationshipToCatalog :: (MonadTx m, MonadReader SystemDefined m, ToJSON a) => QualifiedTable -> RelType -> RelDef a -> m ()
- addEventTriggerToCatalog :: (MonadTx m, Backend ('Postgres pgKind)) => QualifiedTable -> EventTriggerConf ('Postgres pgKind) -> m ()
- addComputedFieldToCatalog :: MonadTx m => AddComputedField ('Postgres 'Vanilla) -> m ()
- addRemoteRelationshipToCatalog :: MonadTx m => CreateFromSourceRelationship ('Postgres 'Vanilla) -> m ()
- addFunctionToCatalog :: (MonadTx m, MonadReader SystemDefined m) => QualifiedFunction -> FunctionConfig -> m ()
- addRemoteSchemaToCatalog :: RemoteSchemaMetadata -> TxE QErr ()
- addCollectionToCatalog :: MonadTx m => CreateCollection -> SystemDefined -> m ()
- addCollectionToAllowlistCatalog :: MonadTx m => CollectionName -> m ()
- setCustomTypesInCatalog :: MonadTx m => CustomTypes -> m ()
- addActionToCatalog :: MonadTx m => CreateAction -> m ()
- addActionPermissionToCatalog :: MonadTx m => CreateActionPermission -> m ()
- addPermissionToCatalog :: (MonadTx m, Backend b) => QualifiedTable -> PermDef b a -> SystemDefined -> m ()
- addCronTriggerToCatalog :: MonadTx m => CronTriggerMetadata -> m ()
- parseLegacyRemoteRelationshipDefinition :: MonadError QErr m => Value -> m RemoteRelationshipDefinition
- fetchMetadataFromHdbTables :: MonadTx m => m MetadataNoSources
- addCronTriggerForeignKeyConstraint :: MonadTx m => m ()
- recreateSystemMetadata :: MonadTx m => m ()
Documentation
saveMetadataToHdbTables :: (MonadTx m, MonadReader SystemDefined m) => MetadataNoSources -> m () Source #
saveTableToCatalog :: (MonadTx m, MonadReader SystemDefined m) => QualifiedTable -> Bool -> TableConfig ('Postgres 'Vanilla) -> m () Source #
insertRelationshipToCatalog :: (MonadTx m, MonadReader SystemDefined m, ToJSON a) => QualifiedTable -> RelType -> RelDef a -> m () Source #
addEventTriggerToCatalog :: (MonadTx m, Backend ('Postgres pgKind)) => QualifiedTable -> EventTriggerConf ('Postgres pgKind) -> m () Source #
addComputedFieldToCatalog :: MonadTx m => AddComputedField ('Postgres 'Vanilla) -> m () Source #
addRemoteRelationshipToCatalog :: MonadTx m => CreateFromSourceRelationship ('Postgres 'Vanilla) -> m () Source #
addFunctionToCatalog :: (MonadTx m, MonadReader SystemDefined m) => QualifiedFunction -> FunctionConfig -> m () Source #
addRemoteSchemaToCatalog :: RemoteSchemaMetadata -> TxE QErr () Source #
addCollectionToCatalog :: MonadTx m => CreateCollection -> SystemDefined -> m () Source #
addCollectionToAllowlistCatalog :: MonadTx m => CollectionName -> m () Source #
setCustomTypesInCatalog :: MonadTx m => CustomTypes -> m () Source #
addActionToCatalog :: MonadTx m => CreateAction -> m () Source #
addActionPermissionToCatalog :: MonadTx m => CreateActionPermission -> m () Source #
addPermissionToCatalog :: (MonadTx m, Backend b) => QualifiedTable -> PermDef b a -> SystemDefined -> m () Source #
addCronTriggerToCatalog :: MonadTx m => CronTriggerMetadata -> m () Source #
parseLegacyRemoteRelationshipDefinition :: MonadError QErr m => Value -> m RemoteRelationshipDefinition Source #
addCronTriggerForeignKeyConstraint :: MonadTx m => m () Source #
recreateSystemMetadata :: MonadTx m => m () Source #
Drops and recreates all “system-defined” metadata, aka metadata for tables and views in the
information_schema
and hdb_catalog
schemas. These tables and views are tracked to expose them
to the console, which allows us to reuse the same functionality we use to implement user-defined
APIs to expose the catalog.
This process has a long and storied history.
In the past, we reused the same machinery we use for CLI migrations to define our own internal
metadata migrations. This caused trouble, however, as we’d have to run those migrations in
lockstep with our SQL migrations to ensure the two didn’t get out of sync. This in turn caused
trouble because those migrations would hit code paths inside graphql-engine
to add or remove
things from the pg_catalog
tables, and that in turn would fail because we hadn’t finished
running the SQL migrations, so we were running a new version of the code against an old version
of the schema! That caused #2826.
To fix that, #2379 switched to the approach of just dropping and recreating all system metadata every time we run any SQL migrations. But that in turn caused trouble due to the way we were constantly rebuilding the schema cache (#3354), causing us to switch to incremental schema cache construction (#3394). However, although that mostly resolved the problem, we still weren’t totally out of the woods, as the incremental construction was still too slow on slow Postgres instances (#3654).
To sidestep the whole issue, as of #3686 we now just create all the system metadata in code here, and we only rebuild the schema cache once, at the very end. This is a little unsatisfying, since it means our internal migrations are “blessed” compared to user-defined CLI migrations. If we improve CLI migrations further in the future, maybe we can switch back to using that approach, instead.