View Source Carbonite.Change (Carbonite v0.12.1)

A Carbonite.Change records a mutation on a database table.

INSERT statements lead to a Change where the data field contains the inserted row as a JSON object while the changed field is an empty list.

UPDATE statements contain the updated record in data while the changed field is a list of attributes that have changed. The changed_from field may additionally contain a partial representation of the replaced record, showing only the diff to the updated record. This behaviour is optional and can be enabled with the store_changed_from trigger option.

DELETE statements have the deleted data in data while changed is again an empty list.

Summary

Types

@type id() :: non_neg_integer()
@type t() :: %Carbonite.Change{
  __meta__: term(),
  changed: [String.t()],
  changed_from: nil | map(),
  data: map(),
  id: id(),
  op: :insert | :update | :delete,
  table_name: String.t(),
  table_pk: nil | [String.t()],
  table_prefix: String.t(),
  transaction: Ecto.Association.NotLoaded.t() | Carbonite.Transaction.t(),
  transaction_id: term(),
  transaction_xact_id: non_neg_integer()
}