feat(models): Recreate CodeReviewEvent with updated schema [3/3]#109424
feat(models): Recreate CodeReviewEvent with updated schema [3/3]#109424
Conversation
|
This PR has a migration; here is the generated SQL for for --
-- Moved model CodeReviewEvent to pending deletion state
--
-- (no-op)for --
-- Delete model CodeReviewEvent
--
DROP TABLE "sentry_code_review_event" CASCADE;for --
-- Create model CodeReviewEvent
--
CREATE TABLE "sentry_code_review_event" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "pr_number" integer NULL, "pr_title" text NULL, "pr_author" text NULL, "pr_url" text NULL, "pr_state" varchar(16) NULL, "raw_event_type" varchar(64) NOT NULL, "raw_event_action" varchar(64) NOT NULL, "trigger_id" varchar(64) NULL, "trigger" varchar(64) NULL, "trigger_user" text NULL, "trigger_at" timestamp with time zone NOT NULL, "target_commit_sha" varchar(64) NULL, "status" varchar(32) NOT NULL, "denial_reason" text NULL, "webhook_received_at" timestamp with time zone NULL, "preflight_completed_at" timestamp with time zone NULL, "task_enqueued_at" timestamp with time zone NULL, "sent_to_seer_at" timestamp with time zone NULL, "review_started_at" timestamp with time zone NULL, "review_completed_at" timestamp with time zone NULL, "seer_run_id" varchar(64) NULL, "comments_posted" integer NULL CHECK ("comments_posted" >= 0), "review_result" jsonb NULL, "organization_id" bigint NOT NULL, "repository_id" bigint NOT NULL);
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or" FOREIGN KEY ("organization_id") REFERENCES "sentry_organization" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or";
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re" FOREIGN KEY ("repository_id") REFERENCES "sentry_repository" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re";
CREATE UNIQUE INDEX CONCURRENTLY "unique_org_repo_trigger_id" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_id") WHERE "trigger_id" IS NOT NULL;
CREATE INDEX CONCURRENTLY "sentry_code_review_event_organization_id_1ce9fe63" ON "sentry_code_review_event" ("organization_id");
CREATE INDEX CONCURRENTLY "sentry_code_review_event_repository_id_a5be62a4" ON "sentry_code_review_event" ("repository_id");
CREATE INDEX CONCURRENTLY "sentry_code_date_ad_a2451c_idx" ON "sentry_code_review_event" ("date_added");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_4f4b09_idx" ON "sentry_code_review_event" ("organization_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_7ba32c_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_76bbd1_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "pr_number"); |
7e4c976 to
756b38d
Compare
1fbe9a4 to
cef3689
Compare
756b38d to
37605c0
Compare
cef3689 to
1f75ef8
Compare
|
This PR has a migration; here is the generated SQL for for --
-- Delete model CodeReviewEvent
--
DROP TABLE "sentry_code_review_event" CASCADE;for --
-- Create model CodeReviewEvent
--
CREATE TABLE "sentry_code_review_event" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "pr_number" integer NULL, "pr_title" text NULL, "pr_author" text NULL, "pr_url" text NULL, "pr_state" varchar(16) NULL, "raw_event_type" varchar(64) NOT NULL, "raw_event_action" varchar(64) NOT NULL, "trigger_id" varchar(64) NULL, "trigger" varchar(64) NULL, "trigger_user" text NULL, "trigger_at" timestamp with time zone NOT NULL, "target_commit_sha" varchar(64) NULL, "status" varchar(32) NOT NULL, "denial_reason" text NULL, "webhook_received_at" timestamp with time zone NULL, "preflight_completed_at" timestamp with time zone NULL, "task_enqueued_at" timestamp with time zone NULL, "sent_to_seer_at" timestamp with time zone NULL, "review_started_at" timestamp with time zone NULL, "review_completed_at" timestamp with time zone NULL, "seer_run_id" varchar(64) NULL, "comments_posted" integer NULL CHECK ("comments_posted" >= 0), "review_result" jsonb NULL, "organization_id" bigint NOT NULL, "repository_id" bigint NOT NULL);
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or" FOREIGN KEY ("organization_id") REFERENCES "sentry_organization" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or";
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re" FOREIGN KEY ("repository_id") REFERENCES "sentry_repository" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re";
CREATE UNIQUE INDEX CONCURRENTLY "unique_org_repo_trigger_id" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_id") WHERE "trigger_id" IS NOT NULL;
CREATE INDEX CONCURRENTLY "sentry_code_review_event_organization_id_1ce9fe63" ON "sentry_code_review_event" ("organization_id");
CREATE INDEX CONCURRENTLY "sentry_code_review_event_repository_id_a5be62a4" ON "sentry_code_review_event" ("repository_id");
CREATE INDEX CONCURRENTLY "sentry_code_date_ad_a2451c_idx" ON "sentry_code_review_event" ("date_added");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_4f4b09_idx" ON "sentry_code_review_event" ("organization_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_7ba32c_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_76bbd1_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "pr_number"); |
| status = models.CharField( | ||
| max_length=32, | ||
| choices=CodeReviewEventStatus.as_choices(), | ||
| default=CodeReviewEventStatus.WEBHOOK_RECEIVED, | ||
| ) |
There was a problem hiding this comment.
I'm wondering if the status can just be derived by looking at the dates, but maybe it's easier to just keep it as a column
There was a problem hiding this comment.
We can't really distinguish based on timestamp fields alone as these are stored for success or failure states both. Plus the stats endpoint (in subsequent PR) filters based on status directly.
1f75ef8 to
3a10139
Compare
|
This PR has a migration; here is the generated SQL for for --
-- Create model CodeReviewEvent
--
CREATE TABLE "sentry_code_review_event" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "pr_number" integer NULL, "pr_title" text NULL, "pr_author" text NULL, "pr_url" text NULL, "pr_state" varchar(16) NULL, "raw_event_type" varchar(64) NOT NULL, "raw_event_action" varchar(64) NOT NULL, "trigger_id" varchar(64) NULL, "trigger" varchar(64) NULL, "trigger_user" text NULL, "trigger_at" timestamp with time zone NOT NULL, "target_commit_sha" varchar(64) NULL, "status" varchar(32) NOT NULL, "denial_reason" text NULL, "webhook_received_at" timestamp with time zone NULL, "preflight_completed_at" timestamp with time zone NULL, "task_enqueued_at" timestamp with time zone NULL, "sent_to_seer_at" timestamp with time zone NULL, "review_started_at" timestamp with time zone NULL, "review_completed_at" timestamp with time zone NULL, "seer_run_id" varchar(64) NULL, "comments_posted" integer NULL CHECK ("comments_posted" >= 0), "review_result" jsonb NULL, "organization_id" bigint NOT NULL, "repository_id" bigint NOT NULL);
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or" FOREIGN KEY ("organization_id") REFERENCES "sentry_organization" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or";
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re" FOREIGN KEY ("repository_id") REFERENCES "sentry_repository" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re";
CREATE UNIQUE INDEX CONCURRENTLY "unique_org_repo_trigger_id" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_id") WHERE "trigger_id" IS NOT NULL;
CREATE INDEX CONCURRENTLY "sentry_code_review_event_organization_id_1ce9fe63" ON "sentry_code_review_event" ("organization_id");
CREATE INDEX CONCURRENTLY "sentry_code_review_event_repository_id_a5be62a4" ON "sentry_code_review_event" ("repository_id");
CREATE INDEX CONCURRENTLY "sentry_code_date_ad_a2451c_idx" ON "sentry_code_review_event" ("date_added");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_4f4b09_idx" ON "sentry_code_review_event" ("organization_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_7ba32c_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_76bbd1_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "pr_number"); |
Backend Test FailuresFailures on
|
c509b64 to
dccf3f6
Compare
|
This PR has a migration; here is the generated SQL for for --
-- Create model CodeReviewEvent
--
CREATE TABLE "sentry_code_review_event" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "pr_number" integer NULL, "pr_title" text NULL, "pr_author" text NULL, "pr_url" text NULL, "pr_state" varchar(16) NULL, "raw_event_type" varchar(64) NOT NULL, "raw_event_action" varchar(64) NOT NULL, "trigger_id" varchar(64) NULL, "trigger" varchar(64) NULL, "trigger_user" text NULL, "trigger_at" timestamp with time zone NOT NULL, "target_commit_sha" varchar(64) NULL, "status" varchar(32) NOT NULL, "denial_reason" text NULL, "webhook_received_at" timestamp with time zone NULL, "preflight_completed_at" timestamp with time zone NULL, "task_enqueued_at" timestamp with time zone NULL, "sent_to_seer_at" timestamp with time zone NULL, "review_started_at" timestamp with time zone NULL, "review_completed_at" timestamp with time zone NULL, "seer_run_id" varchar(64) NULL, "comments_posted" integer NULL CHECK ("comments_posted" >= 0), "review_result" jsonb NULL, "organization_id" bigint NOT NULL, "repository_id" bigint NOT NULL);
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or" FOREIGN KEY ("organization_id") REFERENCES "sentry_organization" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or";
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re" FOREIGN KEY ("repository_id") REFERENCES "sentry_repository" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re";
CREATE UNIQUE INDEX CONCURRENTLY "unique_org_repo_trigger_id" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_id") WHERE "trigger_id" IS NOT NULL;
CREATE INDEX CONCURRENTLY "sentry_code_review_event_organization_id_1ce9fe63" ON "sentry_code_review_event" ("organization_id");
CREATE INDEX CONCURRENTLY "sentry_code_review_event_repository_id_a5be62a4" ON "sentry_code_review_event" ("repository_id");
CREATE INDEX CONCURRENTLY "sentry_code_date_ad_a2451c_idx" ON "sentry_code_review_event" ("date_added");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_4f4b09_idx" ON "sentry_code_review_event" ("organization_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_7ba32c_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_76bbd1_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "pr_number"); |
| denial_reason = models.TextField(null=True) | ||
|
|
||
| # Timestamps for pipeline stages | ||
| webhook_received_at = models.DateTimeField(null=True) |
There was a problem hiding this comment.
Is this the control timestamp? or when the region receives it?
There was a problem hiding this comment.
region, i'll add a note
| # Seer callback data | ||
| seer_run_id = models.CharField(max_length=64, null=True) | ||
| comments_posted = BoundedPositiveIntegerField(null=True) | ||
| review_result = models.JSONField(null=True) |
There was a problem hiding this comment.
the structured fields (seer_run_id, comments_posted, timestamps) capture the key data, while review_result stores the raw/full Seer response payload as JSON for debugging and future use or for stuff where don't really need filtering/queries
adding a comment
| ) | ||
| constraints = [ | ||
| models.UniqueConstraint( | ||
| fields=["organization", "repository", "trigger_id"], |
There was a problem hiding this comment.
What will happen when two rows have a trigger_id of null? (e.g. two events for the same PR come in before we have a trigger_id)
There was a problem hiding this comment.
it's a partial unique index with condition=models.Q(trigger_id__isnull=False), meaning it only enforces uniqueness when trigger_id is non-null
| models.Index(fields=("date_added",)), | ||
| models.Index(fields=("organization", "trigger_at")), | ||
| models.Index(fields=("organization", "repository", "trigger_at")), | ||
| models.Index(fields=("organization", "repository", "pr_number")), |
There was a problem hiding this comment.
We can always expand the indexes as we need to. We can start with none or a smaller subset and expand afterward.
I don't know how to measure the impact of including multiple indexes but it's preferred to add them as needed.
There was a problem hiding this comment.
all 4 indexes have concrete query patterns in PR #108533
- (org, trigger_at) — stats endpoint date-range filters
- (org, repo, trigger_at) — events list endpoint with repo + date filters
- (org, repo, pr_number) — PR grouping/lookup in events endpoint
- (date_added,) — cleanup task purging old rows
d0e994a to
a2af22b
Compare
|
This PR has a migration; here is the generated SQL for for --
-- Create model CodeReviewEvent
--
CREATE TABLE "sentry_code_review_event" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "pr_number" integer NULL, "pr_title" text NULL, "pr_author" text NULL, "pr_url" text NULL, "pr_state" varchar(16) NULL, "raw_event_type" varchar(64) NOT NULL, "raw_event_action" varchar(64) NOT NULL, "trigger_id" varchar(64) NULL, "trigger" varchar(64) NULL, "trigger_user" text NULL, "trigger_at" timestamp with time zone NOT NULL, "target_commit_sha" varchar(64) NULL, "status" varchar(32) NOT NULL, "denial_reason" text NULL, "webhook_received_at" timestamp with time zone NULL, "preflight_completed_at" timestamp with time zone NULL, "task_enqueued_at" timestamp with time zone NULL, "sent_to_seer_at" timestamp with time zone NULL, "review_started_at" timestamp with time zone NULL, "review_completed_at" timestamp with time zone NULL, "seer_run_id" varchar(64) NULL, "comments_posted" integer NULL CHECK ("comments_posted" >= 0), "review_result" jsonb NULL, "organization_id" bigint NOT NULL, "repository_id" bigint NOT NULL);
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or" FOREIGN KEY ("organization_id") REFERENCES "sentry_organization" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or";
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re" FOREIGN KEY ("repository_id") REFERENCES "sentry_repository" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re";
CREATE UNIQUE INDEX CONCURRENTLY "unique_org_repo_trigger_id" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_id") WHERE "trigger_id" IS NOT NULL;
CREATE INDEX CONCURRENTLY "sentry_code_review_event_organization_id_1ce9fe63" ON "sentry_code_review_event" ("organization_id");
CREATE INDEX CONCURRENTLY "sentry_code_review_event_repository_id_a5be62a4" ON "sentry_code_review_event" ("repository_id");
CREATE INDEX CONCURRENTLY "sentry_code_date_ad_a2451c_idx" ON "sentry_code_review_event" ("date_added");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_4f4b09_idx" ON "sentry_code_review_event" ("organization_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_7ba32c_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_76bbd1_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "pr_number"); |
Recreate the CodeReviewEvent table with reviewer feedback applied: - DefaultFieldsModel base class for date_added/date_updated - FlexibleForeignKey for organization and repository (cascade deletion) - RelocationScope.Organization (data preserved during org relocation) - Backup test coverage in create_exhaustive_organization() Migration is a clean auto-generated CreateModel — no manual edits. Co-Authored-By: Claude <noreply@anthropic.com>
Two issues: 1. Change relocation scope from Organization to Global. The model has a FK to Repository which is Global scope — Organization-scoped exports don't include Repository PKs in the pk_map, so CodeReviewEvent instances were filtered out during export. 2. Register DateUpdatedComparator for date_added/date_updated fields. DefaultFieldsModel's auto_now/auto_now_add fields get new timestamps on import, so the comparator must allow timestamp differences. Co-Authored-By: Claude <noreply@anthropic.com>
daf3e1d to
25f9603
Compare
| fields=["organization", "repository", "pr_number"], | ||
| name="sentry_code_organiz_76bbd1_idx", | ||
| ), | ||
| ], | ||
| "constraints": [ | ||
| models.UniqueConstraint( | ||
| condition=models.Q(("trigger_id__isnull", False)), | ||
| fields=("organization", "repository", "trigger_id"), | ||
| name="unique_org_repo_trigger_id", | ||
| ) | ||
| ], |
There was a problem hiding this comment.
Bug: Migration 1042_create_code_review_event is missing a dependency on 1035_delete_code_review_event, which can cause migration failures due to pre-existing table indexes and constraints.
Severity: CRITICAL
Suggested Fix
Update the dependencies in 1042_create_code_review_event.py to depend on ("sentry", "1035_delete_code_review_event") instead of ("sentry", "1041_projectkeymapping"). This ensures the old table is dropped before the new one is created.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/sentry/migrations/1042_create_code_review_event.py#L96-L116
Potential issue: The migration `1042_create_code_review_event` recreates the
`CodeReviewEvent` table, which was deleted by a previous migration,
`1035_delete_code_review_event`. However, migration `1042` incorrectly depends on
`1041_projectkeymapping` instead of `1035`. This lack of an explicit dependency means
the Django migration framework doesn't guarantee the deletion migration runs before the
creation migration. If the ordering is incorrect during deployment, the migration will
fail when attempting to create a table and indexes with names that already exist,
blocking the deployment process.
Did we get this right? 👍 / 👎 to inform future reviews.
|
This PR has a migration; here is the generated SQL for for --
-- Create model CodeReviewEvent
--
CREATE TABLE "sentry_code_review_event" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "pr_number" integer NULL, "pr_title" text NULL, "pr_author" text NULL, "pr_url" text NULL, "pr_state" varchar(16) NULL, "raw_event_type" varchar(64) NOT NULL, "raw_event_action" varchar(64) NOT NULL, "trigger_id" varchar(64) NULL, "trigger" varchar(64) NULL, "trigger_user" text NULL, "trigger_at" timestamp with time zone NOT NULL, "target_commit_sha" varchar(64) NULL, "status" varchar(32) NOT NULL, "denial_reason" text NULL, "webhook_received_at" timestamp with time zone NULL, "preflight_completed_at" timestamp with time zone NULL, "task_enqueued_at" timestamp with time zone NULL, "sent_to_seer_at" timestamp with time zone NULL, "review_started_at" timestamp with time zone NULL, "review_completed_at" timestamp with time zone NULL, "seer_run_id" varchar(64) NULL, "comments_posted" integer NULL CHECK ("comments_posted" >= 0), "review_result" jsonb NULL, "organization_id" bigint NOT NULL, "repository_id" bigint NOT NULL);
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or" FOREIGN KEY ("organization_id") REFERENCES "sentry_organization" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_organization_id_1ce9fe63_fk_sentry_or";
ALTER TABLE "sentry_code_review_event" ADD CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re" FOREIGN KEY ("repository_id") REFERENCES "sentry_repository" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_code_review_event" VALIDATE CONSTRAINT "sentry_code_review_e_repository_id_a5be62a4_fk_sentry_re";
CREATE UNIQUE INDEX CONCURRENTLY "unique_org_repo_trigger_id" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_id") WHERE "trigger_id" IS NOT NULL;
CREATE INDEX CONCURRENTLY "sentry_code_review_event_organization_id_1ce9fe63" ON "sentry_code_review_event" ("organization_id");
CREATE INDEX CONCURRENTLY "sentry_code_review_event_repository_id_a5be62a4" ON "sentry_code_review_event" ("repository_id");
CREATE INDEX CONCURRENTLY "sentry_code_date_ad_a2451c_idx" ON "sentry_code_review_event" ("date_added");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_4f4b09_idx" ON "sentry_code_review_event" ("organization_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_7ba32c_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "trigger_at");
CREATE INDEX CONCURRENTLY "sentry_code_organiz_76bbd1_idx" ON "sentry_code_review_event" ("organization_id", "repository_id", "pr_number"); |
|
Btw, you can ignore the |
…9424) Recreate the `CodeReviewEvent` table with reviewer feedback from PR #108531 applied: - `DefaultFieldsModel` base class for standard `date_added`/`date_updated` fields - `FlexibleForeignKey` for organization and repository (cascade deletion, referential integrity) - `RelocationScope.Global` to match `Repository`'s scope (required for org-scoped exports since Repository is Global) - `DateUpdatedComparator` for `date_added`/`date_updated` in backup comparators - Backup test coverage in `create_exhaustive_organization()` Migration is a clean auto-generated `CreateModel` — no manual edits. **This is PR 3 of 3:** 1. #109420 — `SafeDeleteModel` with `MOVE_TO_PENDING` (merged) 2. #109422 — `SafeDeleteModel` with `DELETE` (merged) 3. **This PR** — Recreate with updated schema --------- Co-authored-by: Claude <noreply@anthropic.com>
Recreate the
CodeReviewEventtable with reviewer feedback from PR #108531 applied:DefaultFieldsModelbase class for standarddate_added/date_updatedfieldsFlexibleForeignKeyfor organization and repository (cascade deletion, referential integrity)RelocationScope.Globalto matchRepository's scope (required for org-scoped exports since Repository is Global)DateUpdatedComparatorfordate_added/date_updatedin backup comparatorscreate_exhaustive_organization()Migration is a clean auto-generated
CreateModel— no manual edits.This is PR 3 of 3:
SafeDeleteModelwithMOVE_TO_PENDING(merged)SafeDeleteModelwithDELETE(merged)