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

  def change do
    create table(:policy_versions, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :policy_type, :string, null: false
      add :version, :string, null: false
      add :content, :text, null: false
      add :effective_date, :utc_datetime, null: false

      timestamps(type: :utc_datetime)
    end

    create index(:policy_versions, [:policy_type])
    create index(:policy_versions, [:effective_date])
    create unique_index(:policy_versions, [:policy_type, :version])
  end
end
