defmodule DaProductApp.Repo.Migrations.CreatePosTransactions do use Ecto.Migration def change do create table(:pos_transactions) do add :transaction_id, :string, null: false add :merchant_id, :string, null: false add :terminal_id, :string add :amount, :decimal, precision: 10, scale: 2, null: false add :currency, :string, default: "AED" add :card_type, :string # 'international', 'domestic' add :card_number_masked, :string add :mcc_code, :string # Merchant Category Code add :status, :string, null: false # 'completed', 'pending', 'failed' add :transaction_time, :utc_datetime, null: false add :location, :string # city/region add :country_code, :string add :settlement_date, :date add :batch_number, :string add :authorization_code, :string add :reference_number, :string add :additional_data, :json timestamps(type: :utc_datetime) end create index(:pos_transactions, [:merchant_id]) create index(:pos_transactions, [:terminal_id]) create index(:pos_transactions, [:status]) create index(:pos_transactions, [:transaction_time]) create index(:pos_transactions, [:card_type]) create index(:pos_transactions, [:mcc_code]) create index(:pos_transactions, [:amount]) create unique_index(:pos_transactions, [:transaction_id]) end end