Skip to content

feat(seer): Add SeerRun FK to SeerNightShiftRun#115694

Merged
trevor-e merged 2 commits into
masterfrom
telkins/add-seer-run-fk-to-night-shift
May 18, 2026
Merged

feat(seer): Add SeerRun FK to SeerNightShiftRun#115694
trevor-e merged 2 commits into
masterfrom
telkins/add-seer-run-fk-to-night-shift

Conversation

@trevor-e
Copy link
Copy Markdown
Member

@trevor-e trevor-e commented May 15, 2026

Summary

  • Adds nullable seer_run FK from SeerNightShiftRun to SeerRun
  • Adds nullable result_seer_run FK from SeerNightShiftRunResult to SeerRun

Context

Prerequisite for linking night shift runs to the Sentry-side run mirror tables. The FKs are nullable initially; TODO to make required once backfilled.

Night shift will use type=EXPLORER with source="night_shift" on SeerAgentRun.

Test plan

  • Migration applies cleanly
  • Existing night shift runs unaffected (FKs are nullable)

🤖 Generated with Claude Code

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/seer/migrations/0015_add_seer_run_fk_to_night_shift.py

for 0015_add_seer_run_fk_to_night_shift in seer

--
-- Add field seer_run to seernightshiftrun
--
ALTER TABLE "seer_nightshiftrun" ADD COLUMN "seer_run_id" bigint NULL;
ALTER TABLE "seer_nightshiftrun" ADD CONSTRAINT "seer_nightshiftrun_seer_run_id_c8367325_fk_seer_seerrun_id" FOREIGN KEY ("seer_run_id") REFERENCES "seer_seerrun" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "seer_nightshiftrun" VALIDATE CONSTRAINT "seer_nightshiftrun_seer_run_id_c8367325_fk_seer_seerrun_id";
CREATE INDEX CONCURRENTLY "seer_nightshiftrun_seer_run_id_c8367325" ON "seer_nightshiftrun" ("seer_run_id");

@trevor-e trevor-e force-pushed the telkins/add-seer-run-fk-to-night-shift branch from cce6f73 to d2cfbe8 Compare May 15, 2026 23:20
@github-actions
Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/seer/migrations/0015_add_agent_run_fks.py

for 0015_add_agent_run_fks in seer

--
-- Add field agent_run to seernightshiftrun
--
ALTER TABLE "seer_nightshiftrun" ADD COLUMN "agent_run_id" bigint NULL;
--
-- Add field agent_run to seernightshiftrunresult
--
ALTER TABLE "seer_nightshiftrunissue" ADD COLUMN "agent_run_id" bigint NULL;
ALTER TABLE "seer_nightshiftrun" ADD CONSTRAINT "seer_nightshiftrun_agent_run_id_c845e7b3_fk_seer_seer" FOREIGN KEY ("agent_run_id") REFERENCES "seer_seeragentrun" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "seer_nightshiftrun" VALIDATE CONSTRAINT "seer_nightshiftrun_agent_run_id_c845e7b3_fk_seer_seer";
CREATE INDEX CONCURRENTLY "seer_nightshiftrun_agent_run_id_c845e7b3" ON "seer_nightshiftrun" ("agent_run_id");
ALTER TABLE "seer_nightshiftrunissue" ADD CONSTRAINT "seer_nightshiftrunis_agent_run_id_dc83e17b_fk_seer_seer" FOREIGN KEY ("agent_run_id") REFERENCES "seer_seeragentrun" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "seer_nightshiftrunissue" VALIDATE CONSTRAINT "seer_nightshiftrunis_agent_run_id_dc83e17b_fk_seer_seer";
CREATE INDEX CONCURRENTLY "seer_nightshiftrunissue_agent_run_id_dc83e17b" ON "seer_nightshiftrunissue" ("agent_run_id");

@trevor-e trevor-e force-pushed the telkins/add-seer-run-fk-to-night-shift branch from d2cfbe8 to 8f3c323 Compare May 15, 2026 23:34
@github-actions
Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/seer/migrations/0015_add_seer_run_fks.py

for 0015_add_seer_run_fks in seer

--
-- Add field seer_run to seernightshiftrun
--
ALTER TABLE "seer_nightshiftrun" ADD COLUMN "seer_run_id" bigint NULL;
--
-- Add field result_seer_run to seernightshiftrunresult
--
ALTER TABLE "seer_nightshiftrunissue" ADD COLUMN "result_seer_run_id" bigint NULL;
ALTER TABLE "seer_nightshiftrun" ADD CONSTRAINT "seer_nightshiftrun_seer_run_id_c8367325_fk_seer_seerrun_id" FOREIGN KEY ("seer_run_id") REFERENCES "seer_seerrun" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "seer_nightshiftrun" VALIDATE CONSTRAINT "seer_nightshiftrun_seer_run_id_c8367325_fk_seer_seerrun_id";
CREATE INDEX CONCURRENTLY "seer_nightshiftrun_seer_run_id_c8367325" ON "seer_nightshiftrun" ("seer_run_id");
ALTER TABLE "seer_nightshiftrunissue" ADD CONSTRAINT "seer_nightshiftrunis_result_seer_run_id_94035eb3_fk_seer_seer" FOREIGN KEY ("result_seer_run_id") REFERENCES "seer_seerrun" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "seer_nightshiftrunissue" VALIDATE CONSTRAINT "seer_nightshiftrunis_result_seer_run_id_94035eb3_fk_seer_seer";
CREATE INDEX CONCURRENTLY "seer_nightshiftrunissue_result_seer_run_id_94035eb3" ON "seer_nightshiftrunissue" ("result_seer_run_id");

Adds nullable FKs to SeerRun:
- SeerNightShiftRun.seer_run (the triage run)
- SeerNightShiftRunResult.result_seer_run (the work run for each result)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@trevor-e trevor-e force-pushed the telkins/add-seer-run-fk-to-night-shift branch from 8f3c323 to 3b602ec Compare May 16, 2026 00:05
Looks up the SeerRun by seer_run_state_id after start_run() and
trigger_autofix_agent() to populate the new FKs. TODO to have those
functions return the SeerRun directly to avoid the lookup.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@trevor-e
Copy link
Copy Markdown
Member Author

@sentry review

@trevor-e trevor-e marked this pull request as ready for review May 18, 2026 16:20
@trevor-e trevor-e requested review from a team as code owners May 18, 2026 16:20
@trevor-e trevor-e merged commit 0023df5 into master May 18, 2026
85 of 87 checks passed
@trevor-e trevor-e deleted the telkins/add-seer-run-fk-to-night-shift branch May 18, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants