1.0 KiB · text History 6280797
defmodule GitGud.Repo.Migrations.CreatePrReviewRequests do
use Ecto.Migration
# Who has been asked to review a pull request.
#
# Separate from `pr_reviews`, which is the append-only log of verdicts
# actually left: a request is outstanding until the person reviews,
# and stays on the row afterwards so the PR page can show that their
# verdict was asked for rather than volunteered.
def change do
create table(:pr_review_requests) do
add :pull_request_id, references(:pull_requests, on_delete: :delete_all), null: false
add :reviewer_id, references(:users, on_delete: :delete_all), null: false
add :requested_by_id, references(:users, on_delete: :nilify_all)
timestamps(type: :utc_datetime, updated_at: false)
end
# One outstanding request per person per PR; asking twice is a no-op.
create unique_index(:pr_review_requests, [:pull_request_id, :reviewer_id])
# "What am I being asked to review?" — the dashboard's query.
create index(:pr_review_requests, [:reviewer_id])
end
end