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

Hasura.RQL.DDL.Schema.Rename

Description

Functions for updating the metadata (with integrity checking) to incorporate schema changes discovered after applying a user-supplied SQL query. None of these functions modify the schema cache, so it must be reloaded after the metadata is updated.

Synopsis

Documentation

data RenameItem (b :: BackendType) a Source #

Constructors

RenameItem 

Fields

data RenameField b Source #

Constructors

RFCol (RenameCol b) 
RFRel (RenameItem b RelName) 

data Rename b Source #

Constructors

RTable (RenameTable b) 
RField (RenameField b) 

otherDeps :: QErrM m => Text -> SchemaObjId -> m () Source #

renameTableInMetadata :: forall b m. (MonadError QErr m, CacheRM m, MonadWriter MetadataModifier m, BackendMetadata b) => SourceName -> TableName b -> TableName b -> m () Source #

Replace all references to a given table name by its new name across the entire metadata.

This function will make use of the metadata dependency graph (see getDependentObjs) to identify all places that refer to the old table name, and replace it accordingly. Most operations will occur within the same source, such as table references in relationships and permissions. Dependencies across sources can happen in the case of cross-source relationships.

This function will fail if it encounters a nonsensical dependency; for instance, if there's a dependency from that table to a source.

For more information about the dependency graph, see SchemaObjId.

renameColumnInMetadata :: forall b m. (MonadError QErr m, CacheRM m, MonadWriter MetadataModifier m, BackendMetadata b) => Column b -> Column b -> SourceName -> TableName b -> FieldInfoMap (FieldInfo b) -> m () Source #

Replace all references to a given column name by its new name across the entire metadata.

This function will make use of the metadata dependency graph (see getDependentObjs) to identify all places that refer to the old column name, and replace it accordingly. Most operations will occur within the same source, such as column references in relationships and permissions. Dependencies across sources can happen in the case of cross-source relationships.

This function will fail if it encounters a nonsensical dependency; for instance, if there's a dependency from that table to a source.

For more information about the dependency graph, see SchemaObjId.

updatePermFlds :: forall b m. (MonadError QErr m, CacheRM m, MonadWriter MetadataModifier m, BackendMetadata b) => SourceName -> TableName b -> RoleName -> PermType -> Rename b -> m () Source #

update fields in permissions

updateColExp :: forall b m. (MonadReader (TableCache b) m, Backend b) => TableName b -> RenameField b -> ColExp -> m ColExp Source #

updateColInRemoteRelationshipLHS :: forall b m. (MonadError QErr m, MonadWriter MetadataModifier m, BackendMetadata b) => SourceName -> RelName -> RenameCol b -> m () Source #

Local helper: update a column's name in the left-hand side of a remote relationship.

There are two kinds or remote relationships: remote source relationships, across sources, and remote schema relationships, on remote schemas. In both cases, we maintain a mapping from the source table's colunns to what they should be joined against in the target; when a column is renamed, those references must be renamed as well. This function handles both cases.

See renameColumnInMetadata.

updateColInRemoteRelationshipRHS :: forall source target m. (MonadWriter MetadataModifier m, Backend source, Backend target) => SourceName -> TableName source -> RelName -> RenameCol target -> m () Source #

Local helper: update a column's name in the right-hand side of a remote relationship.

In the case of remote _source_ relationships, the mapping from column to column needs to be updated if one of the rhs columns has been renamed. A dependency is tracked from the rhs source's column to the lhs source's relationship: when a rhs source's column has been renamed, this function performs the corresponding update in the lhs source's relationship definition.

See renameColumnInMetadata.

updateTableInRemoteRelationshipRHS :: forall source target m. (MonadWriter MetadataModifier m, Backend source, Backend target) => SourceName -> TableName source -> RelName -> RenameTable target -> m () Source #

Local helper: update a table's name in the right-hand side of a remote relationship.

In the case of remote _source_ relationships, the relationship definition targets a specific table in the rhs source, and that reference needs to be updated if the targeted table has been renamed. A dependency is tracked from the rhs source's table to the lhs source's relationship: when a rhs table has been renamed, this function performs the corresponding update in the lhs source's relationship definition.

See renameTableInMetadata.

type ColMap b = HashMap (Column b) (Column b) Source #

getNewCol :: forall b f. Backend b => Functor f => RenameCol b -> TableName b -> f (Column b) -> f (Column b) Source #

updateColMap :: forall b. Backend b => TableName b -> TableName b -> RenameCol b -> ColMap b -> ColMap b Source #