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;
|
||||
Reference in New Issue
Block a user