tarakan/priv/repo/migrations/20260712022742_link_review_tasks_and_scans.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

26 lines
845 B
Elixir

defmodule Tarakan.Repo.Migrations.LinkReviewTasksAndScans do
@moduledoc """
Additive FKs for the Review/Request domain collapse (PR 1a).
- `review_tasks.linked_review_id` → the latest Review created when completing a Request
- `scans.source_request_id` → the Request that produced this Review (history of attempts)
No application behavior change in this migration. Both columns are nullable so
existing rows and ad-hoc Reviews remain valid.
"""
use Ecto.Migration
def change do
alter table(:scans) do
add :source_request_id, references(:review_tasks, on_delete: :nilify_all)
end
alter table(:review_tasks) do
add :linked_review_id, references(:scans, on_delete: :nilify_all)
end
create index(:scans, [:source_request_id])
create index(:review_tasks, [:linked_review_id])
end
end