18 lines
596 B
SQL
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;
|