news/backend/prisma/migrations/20250409200647_add_user_to_collection/migration.sql
2025-04-09 23:25:31 +02:00

18 lines
596 B
SQL

/*
Warnings:
- Added the required column `userId` to the `Collection` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Collection" ADD COLUMN "userId" TEXT;
-- Update existing rows with a default user ID
UPDATE "Collection" SET "userId" = 'default-user-id' WHERE "userId" IS NULL;
-- AlterTable
ALTER TABLE "Collection" ALTER COLUMN "userId" SET NOT NULL;
-- AddForeignKey
ALTER TABLE "Collection" ADD CONSTRAINT "Collection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;