cover/Elixir.DaProductApp.TransactionEventChain.html

1 defmodule DaProductApp.TransactionEventChain do
2 @moduledoc """
3 Ecto schema for the transaction event chain. Each row references an event in
4 a source table (qr_validations, transaction_events, followup_requests, etc.)
5 and links to the previous event for the same transaction, enabling traversal.
6 """
7
8 use Ecto.Schema
9 import Ecto.Changeset
10
11 9 schema "transaction_event_chain" do
12 field :transaction_id, :integer
13 field :event_type, :string
14 field :event_ref_table, :string
15 field :event_ref_id, :integer
16 field :prev_event_id, :integer
17 field :payload, :string
18
19 timestamps()
20 end
21
22 @required ~w(transaction_id event_type event_ref_table)a
23
24 def changeset(struct, attrs) do
25 struct
26 |> cast(attrs, [:transaction_id, :event_type, :event_ref_table, :event_ref_id, :prev_event_id, :payload])
27 1 |> validate_required(@required)
28 end
29 end
Line Hits Source