fix(schema): cascade-delete VideoConfig/LintResult/BulkJobItem/VideoPlaylist with their Video
Channel import crashed on the hard-delete purge path (videos confirmed gone from YouTube for 30+ days): prisma.video.deleteMany() hit a FK violation on VideoConfig_videoId_fkey. All four required relations pointing at Video had no onDelete behavior set, defaulting to RESTRICT - any of the four would have hit the same crash, not just VideoConfig. First real channel import against a real, aged dataset is what surfaced this; nothing had exercised the 30-day hard-delete path before.
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "BulkJobItem" DROP CONSTRAINT "BulkJobItem_videoId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "LintResult" DROP CONSTRAINT "LintResult_videoId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "VideoConfig" DROP CONSTRAINT "VideoConfig_videoId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "VideoPlaylist" DROP CONSTRAINT "VideoPlaylist_videoId_fkey";
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "VideoConfig" ADD CONSTRAINT "VideoConfig_videoId_fkey" FOREIGN KEY ("videoId") REFERENCES "Video"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "LintResult" ADD CONSTRAINT "LintResult_videoId_fkey" FOREIGN KEY ("videoId") REFERENCES "Video"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "BulkJobItem" ADD CONSTRAINT "BulkJobItem_videoId_fkey" FOREIGN KEY ("videoId") REFERENCES "Video"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "VideoPlaylist" ADD CONSTRAINT "VideoPlaylist_videoId_fkey" FOREIGN KEY ("videoId") REFERENCES "Video"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
@@ -174,7 +174,7 @@ enum LintStatus {
|
|||||||
model VideoConfig {
|
model VideoConfig {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
videoId String @unique
|
videoId String @unique
|
||||||
video Video @relation(fields: [videoId], references: [id])
|
video Video @relation(fields: [videoId], references: [id], onDelete: Cascade)
|
||||||
templateId String?
|
templateId String?
|
||||||
blockOrder Json
|
blockOrder Json
|
||||||
blockOverrides Json
|
blockOverrides Json
|
||||||
@@ -312,7 +312,7 @@ model SavedView {
|
|||||||
model LintResult {
|
model LintResult {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
videoId String
|
videoId String
|
||||||
video Video @relation(fields: [videoId], references: [id])
|
video Video @relation(fields: [videoId], references: [id], onDelete: Cascade)
|
||||||
ruleCode String
|
ruleCode String
|
||||||
severity LintSeverity
|
severity LintSeverity
|
||||||
targetField String?
|
targetField String?
|
||||||
@@ -369,7 +369,7 @@ model BulkJobItem {
|
|||||||
bulkJobId String
|
bulkJobId String
|
||||||
bulkJob BulkJob @relation(fields: [bulkJobId], references: [id])
|
bulkJob BulkJob @relation(fields: [bulkJobId], references: [id])
|
||||||
videoId String
|
videoId String
|
||||||
video Video @relation(fields: [videoId], references: [id])
|
video Video @relation(fields: [videoId], references: [id], onDelete: Cascade)
|
||||||
beforeSnapshot Json?
|
beforeSnapshot Json?
|
||||||
afterSnapshot Json?
|
afterSnapshot Json?
|
||||||
status String @default("pending")
|
status String @default("pending")
|
||||||
@@ -415,7 +415,7 @@ model VideoPlaylist {
|
|||||||
videoId String
|
videoId String
|
||||||
playlistId String
|
playlistId String
|
||||||
position Int?
|
position Int?
|
||||||
video Video @relation(fields: [videoId], references: [id])
|
video Video @relation(fields: [videoId], references: [id], onDelete: Cascade)
|
||||||
playlist Playlist @relation(fields: [playlistId], references: [id])
|
playlist Playlist @relation(fields: [playlistId], references: [id])
|
||||||
|
|
||||||
@@id([videoId, playlistId])
|
@@id([videoId, playlistId])
|
||||||
|
|||||||
Reference in New Issue
Block a user