Carbonite.Migrations (Carbonite v0.3.1) View Source

Functions to setup Carbonite audit trails in your migrations.

Link to this section Summary

Functions

Alters a triggers configuration for a given table.

Removes a Carbonite audit trail from the database.

Removes a Carbonite audit trail from the database but keeps the schema.

Removes a change capture trigger from a table.

Installs a Carbonite audit trail.

Installs a change capture trigger on a table.

Link to this section Types

Specs

column_name() :: binary()

Specs

prefix() :: binary() | atom()

Specs

schema_option() :: {:carbonite_prefix, prefix()}

Specs

table_name() :: binary() | atom()
Link to this type

trigger_config_option()

View Source

Specs

trigger_config_option() ::
  {:primary_key_columns, [column_name()]}
  | {:excluded_columns, [column_name()]}
  | {:mode, :capture | :ignore}

Specs

trigger_option() :: {:table_prefix, prefix()} | {:carbonite_prefix, prefix()}

Link to this section Functions

Link to this function

configure_trigger(table_name, opts \\ [])

View Source (since 0.1.0)

Specs

configure_trigger(table_name(), [trigger_option() | trigger_config_option()]) ::
  :ok

Alters a triggers configuration for a given table.

You need to specify all desired options each time you call this function, as the previous configuration will be replaced.

Options

  • table_prefix is the name of the schema the table lives in
  • carbonite_prefix is the schema of the audit trail, defaults to "carbonite_default"
  • primary_key_columns is a list of columns that form the primary key of the table
                      (defaults to `["id"]`, set to `[]` to disable)
  • excluded_columns is a list of columns to exclude from change captures
  • filtered_columns is a list of columns that appear as '[FILTERED]' in the data
  • mode is either :capture or :ignore and defines the default behaviour of the trigger
Link to this function

drop_schema(opts \\ [])

View Source (since 0.1.0)

Specs

drop_schema([schema_option()]) :: :ok

Removes a Carbonite audit trail from the database.

Options

  • carbonite_prefix defines the audit trail's schema, defaults to "carbonite_default"
Link to this function

drop_tables(opts \\ [])

View Source (since 0.3.0)

Specs

drop_tables([schema_option()]) :: :ok

Removes a Carbonite audit trail from the database but keeps the schema.

Options

  • carbonite_prefix defines the audit trail's schema, defaults to "carbonite_default"
Link to this function

drop_trigger(table_name, opts \\ [])

View Source (since 0.1.0)

Specs

drop_trigger(table_name(), [trigger_option()]) :: :ok

Removes a change capture trigger from a table.

Options

  • table_prefix is the name of the schema the table lives in
  • carbonite_prefix is the schema of the audit trail, defaults to "carbonite_default"
Link to this function

install_schema(opts \\ [])

View Source (since 0.1.0)

Specs

install_schema([schema_option()]) :: :ok

Installs a Carbonite audit trail.

Options

  • carbonite_prefix defines the audit trail's schema, defaults to "carbonite_default"
Link to this function

install_trigger(table_name, opts \\ [])

View Source (since 0.1.0)

Specs

install_trigger(table_name(), [trigger_option() | trigger_config_option()]) ::
  :ok

Installs a change capture trigger on a table.

Options

  • table_prefix is the name of the schema the table lives in
  • carbonite_prefix is the schema of the audit trail, defaults to "carbonite_default"
  • primary_key_columns is a list of columns that form the primary key of the table
                      (defaults to `["id"]`, set to `[]` to disable)
  • excluded_columns is a list of columns to exclude from change captures
  • filtered_columns is a list of columns that appear as '[FILTERED]' in the data