-
Notifications
You must be signed in to change notification settings - Fork 145
refactor: link video jobs to logs by internal id #2711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
0371d77
8881430
be23096
bf59c77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ALTER TABLE "video_job" ADD COLUMN "log_id" text;--> statement-breakpoint | ||
| UPDATE "video_job" SET "log_id" = "log"."id" FROM "log" WHERE "log"."request_id" = "video_job"."request_id";--> statement-breakpoint | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This backfill matches only on Useful? React with 👍 / 👎. |
||
| CREATE INDEX "video_job_log_id_idx" ON "video_job" ("log_id");--> statement-breakpoint | ||
| ALTER TABLE "video_job" ADD CONSTRAINT "video_job_log_id_log_id_fkey" FOREIGN KEY ("log_id") REFERENCES "log"("id") ON DELETE SET NULL; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a terminal video job is finalized, this update writes a freshly generated
logIdbeforetx.insert(tables.log)creates that row. The migration adds a non-deferrable FK fromvideo_job.log_idtolog.id, so Postgres checks this statement immediately and rejects every first-time finalization with a foreign-key violation; the transaction never reaches the log insert, so completed/failed video jobs are not logged and the rest of finalization cannot run. Insert the log first or assignlogIdin a second update after the insert.Useful? React with 👍 / 👎.