defmodule Microwaveprop.Repo.Migrations.CreateImportRuns do
  use Ecto.Migration

  def change do
    create table(:import_runs, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :submitter_email, :string, null: false
      add :rows, :map, null: false
      add :total_rows, :integer, null: false
      add :processed_rows, :integer, null: false, default: 0
      add :imported_count, :integer, null: false, default: 0
      add :refined_count, :integer, null: false, default: 0
      add :error_count, :integer, null: false, default: 0
      add :errors, :map, null: false, default: %{}
      add :status, :string, null: false, default: "pending"
      add :started_at, :utc_datetime_usec
      add :completed_at, :utc_datetime_usec

      timestamps(type: :utc_datetime_usec)
    end

    create index(:import_runs, [:submitter_email])
    create index(:import_runs, [:status])
  end
end
