Skip to main content

priv/templates/add_consent_records_table.exs.eex

defmodule <%= module_prefix %>.Repo.Migrations.AddConsentRecordsTable do
  use Ecto.Migration

  def up do
    create table(:consent_records, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :consent_id, :binary_id, null: false
      add :categories, <%= categories_column %>, null: false
      add :changed_categories, <%= categories_column %>
      add :revision, :integer
      add :language, :string, size: 10
      add :country_iso, :string, size: 3
      add :masked_ip, :string, size: 45

      add :inserted_at, :utc_datetime, null: false
    end

    create index(:consent_records, [:consent_id])
    create index(:consent_records, [:inserted_at])
    create index(:consent_records, [:country_iso])
  end

  def down do
    drop table(:consent_records)
  end
end