defmodule DaProductApp.Repo.Migrations.CreateReqPays do use Ecto.Migration def change do create table(:req_pays) do # Core UPI fields for payment request add :txn_id, :string, size: 50 add :msg_id, :string, null: false, size: 35 add :org_id, :string, null: false, size: 10 add :ref_id, :string, size: 35 add :ref_url, :string, size: 255 add :payer_addr, :string, size: 255 add :payee_addr, :string, size: 255 add :payer_name, :string, size: 100 add :payee_name, :string, size: 100 add :network_inst_id, :string, size: 20 add :payment_type, :string, size: 20 add :payment_purpose, :string, size: 100 # Amount fields add :amount, :decimal, precision: 18, scale: 2, null: false add :currency, :string, size: 3, null: false # Response fields add :response_code, :string, size: 10 add :response_message, :string, size: 255 add :payment_status, :string, size: 20 add :settlement_status, :string, size: 20 add :npci_txn_id, :string, size: 50 add :rrn, :string, size: 50 # International fields add :corridor, :string, size: 20 add :partner_txn_id, :string, size: 50 add :fx_rate, :decimal, precision: 18, scale: 8 add :base_amount, :decimal, precision: 18, scale: 6 add :base_currency, :string, size: 3 # QR specific fields add :qr_string, :text add :qr_medium, :string, size: 20 add :merchant_category_code, :string, size: 10 add :merchant_vpa, :string, size: 255 # Status and tracking add :status, :string, null: false, default: "PENDING", size: 20 add :validation_type, :string, null: false, size: 20 add :error_code, :string, size: 10 add :error_message, :string, size: 255 # Timestamps add :npci_request_received_at, :utc_datetime add :npci_response_sent_at, :utc_datetime add :processing_duration_ms, :integer add :paid_at, :utc_datetime # Foreign keys add :transaction_id, :bigint add :partner_id, :binary, size: 16 add :merchant_id, :bigint # Store raw XML as hashes/blobs for audit add :req_xml_hash, :binary add :resp_xml_hash, :binary timestamps(type: :utc_datetime) end create unique_index(:req_pays, [:msg_id]) create index(:req_pays, [:transaction_id]) create index(:req_pays, [:org_id]) create index(:req_pays, [:status]) create index(:req_pays, [:validation_type]) create index(:req_pays, [:payment_status]) create index(:req_pays, [:partner_id]) create index(:req_pays, [:merchant_id]) create index(:req_pays, [:npci_txn_id]) create index(:req_pays, [:rrn]) create index(:req_pays, [:corridor]) create index(:req_pays, [:npci_request_received_at]) end end