tarakan/priv/repo/migrations/20260710225052_add_review_provenance.exs
Maxfield Luke af6077b9c3
All checks were successful
CI and deploy / Test (push) Successful in 4m52s
CI and deploy / Deploy production (push) Successful in 23s
Initial commit on Forgejo
Fresh repository history for elektrine/tarakan hosted at
https://git.elektrine.com/elektrine/tarakan.
2026-07-29 04:43:40 -04:00

49 lines
1.6 KiB
Elixir

defmodule Tarakan.Repo.Migrations.AddReviewProvenance do
use Ecto.Migration
def change do
drop_if_exists index(
:scans,
[:repository_id, :submitted_by_id, :commit_sha, :model, :prompt_version],
name: :scans_unique_submission_index
)
alter table(:scans) do
add :provenance, :string, null: false, default: "agent"
add :review_kind, :string, null: false, default: "code_review"
modify :model, :string, null: true, from: {:string, null: false}
modify :prompt_version, :string, null: true, from: {:string, null: false}
end
create unique_index(
:scans,
[
:repository_id,
:submitted_by_id,
:commit_sha,
:provenance,
:review_kind,
"COALESCE(model, '')",
"COALESCE(prompt_version, '')"
],
name: :scans_unique_submission_index
)
create constraint(:scans, :scans_provenance_must_be_valid,
check: "provenance IN ('agent', 'human', 'hybrid')"
)
create constraint(:scans, :scans_review_kind_must_be_valid,
check:
"review_kind IN ('code_review', 'threat_model', 'privacy_review', 'business_logic')"
)
alter table(:scan_confirmations) do
add :provenance, :string, null: false, default: "human"
end
create constraint(:scan_confirmations, :scan_confirmations_provenance_must_be_valid,
check: "provenance IN ('agent', 'human', 'hybrid')"
)
end
end