defmodule DaProductApp.Repo.Migrations.CreateMerchantBatchNumbers do use Ecto.Migration def change do create table(:merchant_batch_numbers, primary_key: false) do add :id, :binary_id, primary_key: true add :merchant_id, :string, null: false add :batch_number, :integer, null: false, default: 1 add :provider_id, :integer, null: true timestamps(type: :utc_datetime) end create unique_index(:merchant_batch_numbers, [:merchant_id, :provider_id], name: :merchant_provider_unique_idx) # If you want to keep the old index for backward compatibility, uncomment below: # create unique_index(:merchant_batch_numbers, [:merchant_id]) create index(:merchant_batch_numbers, [:merchant_id, :provider_id]) end end