defmodule DaProductApp.TransactionEventChain do @moduledoc """ Ecto schema for the transaction event chain. Each row references an event in a source table (qr_validations, transaction_events, followup_requests, etc.) and links to the previous event for the same transaction, enabling traversal. """ use Ecto.Schema import Ecto.Changeset schema "transaction_event_chain" do field :transaction_id, :integer field :event_type, :string field :event_ref_table, :string field :event_ref_id, :integer field :prev_event_id, :integer field :payload, :string timestamps() end @required ~w(transaction_id event_type event_ref_table)a def changeset(struct, attrs) do struct |> cast(attrs, [:transaction_id, :event_type, :event_ref_table, :event_ref_id, :prev_event_id, :payload]) |> validate_required(@required) end end