Sublimate. ProjectionHelpers
(Sublimate v0.1.0)
Copy Markdown
Helper functions for Sublimate.ProjectionData.
Summary
Functions
Checks whether projection_data.identity_column is present in table_columns and is a valid identity column.
Checks whether projection_data.identity_column does not already exist in table_columns.
Returns an error if the identity column is present in table_columns.
Adds an identity column to the source table if it isn't already present.
Checks whether projection_data.identity_column is already present in table_columns and is a valid identity column.
This is the inverse of identity_column_exists?/2.
Types
Functions
@spec identity_column_exists?( projection_data :: Sublimate.ProjectionData.t(), table_columns :: table_columns() ) :: :ok | {:error, :identity_column_not_found, String.t()} | {:error, :identity_column_invalid_type, String.t()}
Checks whether projection_data.identity_column is present in table_columns and is a valid identity column.
An identity column is either a serial column or an integer column that is a primary key.
Returns an error if:
projection_data.identity_columnis not found intable_columns- the identity column has an invalid type
@spec identity_column_is_new?( projection_data :: Sublimate.ProjectionData.t(), table_columns :: table_columns() ) :: :ok | {:error, :identity_column_already_exists}
Checks whether projection_data.identity_column does not already exist in table_columns.
Returns an error if the identity column is present in table_columns.
@spec maybe_add_identity_column( projection_data :: Sublimate.ProjectionData.t(), table_columns :: table_columns(), repo :: repo(), postgrex_options :: postgrex_options() ) :: {:ok, table_columns()} | {:error, :identity_column_already_exists} | {:error, Exception.t()}
Adds an identity column to the source table if it isn't already present.
Returns an error if the identity column already exists.
@spec needs_identity_column?( projection_data :: Sublimate.ProjectionData.t(), table_columns :: table_columns() ) :: :ok | {:error, :identity_column_already_exists}
Checks whether projection_data.identity_column is already present in table_columns and is a valid identity column.
This is the inverse of identity_column_exists?/2.
Returns an error if projection_data.identity_column is found in table_columns and has a valid type.