comicbox/prisma/migrations/20220724154258_add_image_dimensions/migration.sql

27 lines
1.1 KiB
SQL

/*
Warnings:
- Added the required column `height` to the `ComicPage` table without a default value. This is not possible if the table is not empty.
- Added the required column `width` to the `ComicPage` table without a default value. This is not possible if the table is not empty.
*/
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_ComicPage" (
"id" INTEGER NOT NULL,
"comicId" INTEGER NOT NULL,
"title" TEXT NOT NULL,
"url" TEXT NOT NULL,
"imageUrl" TEXT NOT NULL,
"width" INTEGER NOT NULL,
"height" INTEGER NOT NULL,
PRIMARY KEY ("comicId", "id"),
CONSTRAINT "ComicPage_comicId_fkey" FOREIGN KEY ("comicId") REFERENCES "Comic" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_ComicPage" ("comicId", "id", "imageUrl", "title", "url") SELECT "comicId", "id", "imageUrl", "title", "url" FROM "ComicPage";
DROP TABLE "ComicPage";
ALTER TABLE "new_ComicPage" RENAME TO "ComicPage";
CREATE UNIQUE INDEX "ComicPage_comicId_id_key" ON "ComicPage"("comicId", "id");
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;