defmodule Towerops.Repo.Migrations.AddSourceToPreseemInsights do
  use Ecto.Migration

  def change do
    alter table(:preseem_insights) do
      add :source, :string, null: false, default: "preseem"
      add :site_id, references(:sites, type: :binary_id, on_delete: :nilify_all)
      add :agent_token_id, references(:agent_tokens, type: :binary_id, on_delete: :nilify_all)
    end

    create index(:preseem_insights, [:organization_id, :source, :status])
    create index(:preseem_insights, [:site_id])
    create index(:preseem_insights, [:agent_token_id])
  end
end
