Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- class ToMetadataFetchQuery (pgKind :: PostgresKind)
- resolveSourceConfig :: (MonadIO m, MonadResolveSource m) => SourceName -> PostgresConnConfiguration -> BackendSourceKind ('Postgres pgKind) -> BackendConfig ('Postgres pgKind) -> Environment -> manager -> m (Either QErr (SourceConfig ('Postgres pgKind)))
- logPGSourceCatalogMigrationLockedQueries :: MonadIO m => Logger Hasura -> PGSourceConfig -> m Void
- resolveDatabaseMetadata :: forall pgKind m. (Backend ('Postgres pgKind), ToMetadataFetchQuery pgKind, FetchFunctionMetadata pgKind, FetchTableMetadata pgKind, MonadIO m, MonadBaseControl IO m) => SourceMetadata ('Postgres pgKind) -> SourceConfig ('Postgres pgKind) -> m (Either QErr (DBObjectsIntrospection ('Postgres pgKind)))
- prepareCatalog :: (MonadIO m, MonadBaseControl IO m) => SourceConfig ('Postgres pgKind) -> ExceptT QErr m (RecreateEventTriggers, SourceCatalogMigrationState)
- class FetchTableMetadata (pgKind :: PostgresKind) where
- fetchTableMetadata :: forall m. (Backend ('Postgres pgKind), ToMetadataFetchQuery pgKind, MonadTx m) => HashSet QualifiedTable -> m (DBTablesMetadata ('Postgres pgKind))
- pgFetchTableMetadata :: forall pgKind m. (Backend ('Postgres pgKind), ToMetadataFetchQuery pgKind, MonadTx m) => HashSet QualifiedTable -> m (DBTablesMetadata ('Postgres pgKind))
- class FetchFunctionMetadata (pgKind :: PostgresKind) where
- fetchFunctionMetadata :: MonadTx m => HashSet QualifiedFunction -> m (DBFunctionsMetadata ('Postgres pgKind))
- postDropSourceHook :: (MonadIO m, MonadError QErr m, MonadBaseControl IO m) => SourceConfig ('Postgres pgKind) -> TableEventTriggers ('Postgres pgKind) -> m ()
Documentation
class ToMetadataFetchQuery (pgKind :: PostgresKind) 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.
tableMetadata
Instances
resolveSourceConfig :: (MonadIO m, MonadResolveSource m) => SourceName -> PostgresConnConfiguration -> BackendSourceKind ('Postgres pgKind) -> BackendConfig ('Postgres pgKind) -> Environment -> manager -> m (Either QErr (SourceConfig ('Postgres pgKind))) Source #
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) -> m (Either QErr (DBObjectsIntrospection ('Postgres pgKind))) Source #
prepareCatalog :: (MonadIO m, MonadBaseControl IO m) => SourceConfig ('Postgres pgKind) -> ExceptT QErr m (RecreateEventTriggers, SourceCatalogMigrationState) Source #
Initialise catalog tables for a source, including those required by the event delivery subsystem.
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
fetchTableMetadata :: forall m. (Backend ('Postgres pgKind), ToMetadataFetchQuery pgKind, MonadTx m) => HashSet QualifiedTable -> m (DBTablesMetadata ('Postgres pgKind)) Source #
Instances
FetchTableMetadata 'Citus Source # | |
Defined in Hasura.Backends.Postgres.DDL.Source fetchTableMetadata :: (Backend ('Postgres 'Citus), ToMetadataFetchQuery 'Citus, MonadTx m) => HashSet QualifiedTable -> m (DBTablesMetadata ('Postgres 'Citus)) Source # | |
FetchTableMetadata 'Cockroach Source # | |
Defined in Hasura.Backends.Postgres.DDL.Source fetchTableMetadata :: (Backend ('Postgres 'Cockroach), ToMetadataFetchQuery 'Cockroach, MonadTx m) => HashSet QualifiedTable -> m (DBTablesMetadata ('Postgres 'Cockroach)) Source # | |
FetchTableMetadata 'Vanilla Source # | |
Defined in Hasura.Backends.Postgres.DDL.Source fetchTableMetadata :: (Backend ('Postgres 'Vanilla), ToMetadataFetchQuery 'Vanilla, MonadTx m) => HashSet QualifiedTable -> m (DBTablesMetadata ('Postgres 'Vanilla)) Source # |
pgFetchTableMetadata :: forall pgKind m. (Backend ('Postgres pgKind), ToMetadataFetchQuery pgKind, MonadTx m) => HashSet QualifiedTable -> m (DBTablesMetadata ('Postgres pgKind)) Source #
Fetch Postgres metadata of all user tables
class FetchFunctionMetadata (pgKind :: PostgresKind) where Source #
fetchFunctionMetadata :: MonadTx m => HashSet QualifiedFunction -> m (DBFunctionsMetadata ('Postgres pgKind)) Source #
Instances
FetchFunctionMetadata 'Citus Source # | |
Defined in Hasura.Backends.Postgres.DDL.Source fetchFunctionMetadata :: MonadTx m => HashSet QualifiedFunction -> m (DBFunctionsMetadata ('Postgres 'Citus)) Source # | |
FetchFunctionMetadata 'Cockroach Source # | |
Defined in Hasura.Backends.Postgres.DDL.Source fetchFunctionMetadata :: MonadTx m => HashSet QualifiedFunction -> m (DBFunctionsMetadata ('Postgres 'Cockroach)) Source # | |
FetchFunctionMetadata 'Vanilla Source # | |
Defined in Hasura.Backends.Postgres.DDL.Source fetchFunctionMetadata :: MonadTx m => HashSet QualifiedFunction -> m (DBFunctionsMetadata ('Postgres 'Vanilla)) Source # |
postDropSourceHook :: (MonadIO m, MonadError QErr m, MonadBaseControl IO m) => SourceConfig ('Postgres pgKind) -> TableEventTriggers ('Postgres pgKind) -> m () Source #
Clean source database after dropping in metadata