defmodule DaProductApp.Repo.Migrations.CreateApiKeyOperations do use Ecto.Migration def change do create table(:api_key_operations, primary_key: false) do add :id, :binary_id, primary_key: true add :partner_id, references(:partners, on_delete: :delete_all, type: :binary_id), null: false add :operation_type, :string, null: false add :api_key_hash, :string add :ip_address, :string add :user_agent, :text add :success, :boolean, null: false, default: false add :failure_reason, :string add :metadata, :map timestamps(type: :utc_datetime) end create index(:api_key_operations, [:partner_id]) create index(:api_key_operations, [:operation_type]) create index(:api_key_operations, [:inserted_at]) create index(:api_key_operations, [:partner_id, :operation_type]) create index(:api_key_operations, [:success]) end end