graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.Backends.Postgres.DDL.Source

Description

Postgres DDL Source

A Source is a connected database. One can have multiple sources of the same kind (e.g. Postgres).

This module provides ways to fetch, update, and deal with table and function metadata and hdb_catalog migrations for a Postgres Source.

NOTE: Please have a look at the `serverdocumentationmigration-guidelines.md` before adding any new migration if you haven't already looked at it.

Synopsis

Documentation

class ToMetadataFetchQuery (pgKind :: PostgresKind) where Source #

We differentiate the handling of metadata between Citus, Cockroach and Vanilla Postgres because Citus imposes limitations on the types of joins that it permits, which then limits the types of relations that we can track.

Methods

tableMetadata :: Query Source #

Instances

Instances details
ToMetadataFetchQuery 'Vanilla Source # 
Instance details

Defined in Hasura.Backends.Postgres.DDL.Source

Methods

tableMetadata :: Query Source #

ToMetadataFetchQuery 'Citus Source # 
Instance details

Defined in Hasura.Backends.Postgres.DDL.Source

Methods

tableMetadata :: Query Source #

ToMetadataFetchQuery 'Cockroach Source # 
Instance details

Defined in Hasura.Backends.Postgres.DDL.Source

Methods

tableMetadata :: Query Source #

data PGSourceLockQuery Source #

PGSourceLockQuery is a data type which represents the contents of a single object of the locked queries which are queried from the pg_stat_activity. See logPGSourceCatalogMigrationLockedQueries.

logPGSourceCatalogMigrationLockedQueries :: MonadIO m => Logger Hasura -> PGSourceConfig -> m Void Source #

logPGSourceCatalogMigrationLockedQueries as the name suggests logs the queries which are blocking in the database. This function is called asynchronously from initCatalogIfNeeded while the source catalog is being migrated. NOTE: When there are no locking queries present in the database, nothing will be logged.

resolveDatabaseMetadata :: forall pgKind m. (Backend ('Postgres pgKind), ToMetadataFetchQuery pgKind, FetchFunctionMetadata pgKind, FetchTableMetadata pgKind, MonadIO m, MonadBaseControl IO m) => SourceMetadata ('Postgres pgKind) -> SourceConfig ('Postgres pgKind) -> SourceTypeCustomization -> m (Either QErr (ResolvedSource ('Postgres pgKind))) Source #

prepareCatalog :: (MonadIO m, MonadBaseControl IO m) => SourceConfig ('Postgres pgKind) -> ExceptT QErr m RecreateEventTriggers Source #

Initialise catalog tables for a source, including those required by the event delivery subsystem.

migrateSourceCatalogFrom :: MonadTx m => SourceCatalogVersion pgKind -> m RecreateEventTriggers Source #

migrateSourceCatalogFrom migrates the catalog from a lower to a higher version. When there are any changes in the source catalog, then re-create the existing event triggers in the metadata. This is done so that the event triggers be compatible with the changes introduced in the newly added source catalog migrations. When the source is already in the latest catalog version, we do nothing because nothing has changed w.r.t the source catalog so recreating the event triggers will only be extraneous.

class FetchTableMetadata (pgKind :: PostgresKind) where Source #

We differentiate for CockroachDB and other PG implementations as our CockroachDB table fetching SQL does not require table information, and fails if it receives unused prepared arguments this distinction should no longer be necessary if this issue is resolved: https://github.com/cockroachdb/cockroach/issues/86375

Methods

fetchTableMetadata :: forall m. (Backend ('Postgres pgKind), ToMetadataFetchQuery pgKind, MonadTx m) => [QualifiedTable] -> m (DBTablesMetadata ('Postgres pgKind)) Source #

pgFetchTableMetadata :: forall pgKind m. (Backend ('Postgres pgKind), ToMetadataFetchQuery pgKind, MonadTx m) => [QualifiedTable] -> m (DBTablesMetadata ('Postgres pgKind)) Source #

Fetch Postgres metadata of all user tables

cockroachFetchTableMetadata :: forall pgKind m. (Backend ('Postgres pgKind), ToMetadataFetchQuery pgKind, MonadTx m) => [QualifiedTable] -> m (DBTablesMetadata ('Postgres pgKind)) Source #

Fetch Cockroach metadata of all user tables

pgFetchFunctionMetadata :: MonadTx m => [QualifiedFunction] -> m (DBFunctionsMetadata ('Postgres pgKind)) Source #

Fetch Postgres metadata for all user functions

fetchPgScalars :: MonadTx m => m (HashSet PGScalarType) Source #

Fetch all scalar types from Postgres

postDropSourceHook :: (MonadIO m, MonadError QErr m, MonadBaseControl IO m) => SourceConfig ('Postgres pgKind) -> TableEventTriggers ('Postgres pgKind) -> m () Source #

Clean source database after dropping in metadata