defmodule DaProductApp.Repo.Migrations.CreateInterchangeRates do use Ecto.Migration @moduledoc """ Interchange rate master table — Mercury's cost per transaction from card schemes. Used in Settlement MIS to calculate Mercury's cost and profitability at transaction level (spec requirement: interchange rates in Settlement MIS). If actual interchange is not received from YSP for a transaction, the system falls back to this master table to estimate cost using card_type_id + scheme. Data source: Interchange table from YSP (pending — table created now). """ def change do create table(:interchange_rates) do add :card_type_id, :bigint, null: false, comment: "shukria_mms card_types.id" add :card_type_code, :string, size: 50, comment: "Denormalized for display" add :scheme_name, :string, size: 30, comment: "VISA | MASTERCARD | AMEX | UNIONPAY" add :rate_percentage, :decimal, precision: 8, scale: 4, null: false add :fixed_fee, :decimal, precision: 10, scale: 2, null: false, default: 0 add :effective_from, :date add :effective_to, :date add :status, :integer, null: false, default: 1, comment: "1 = active, 0 = inactive" add :notes, :text add :inserted_at, :naive_datetime, null: false add :updated_at, :naive_datetime, null: false end create index(:interchange_rates, [:card_type_id]) create index(:interchange_rates, [:scheme_name]) create index(:interchange_rates, [:effective_from, :effective_to]) create index(:interchange_rates, [:status]) end end