panorama/prisma/migrations/20230418213945_meta_cascade_on_delete/migration.sql
Michael Zhang 97774d5852
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
todo app crud
2023-04-18 16:44:44 -05:00

18 lines
801 B
SQL

-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_NodeMeta" (
"nodeId" TEXT NOT NULL,
"appId" TEXT NOT NULL,
"appKey" TEXT NOT NULL,
"value" BLOB NOT NULL,
PRIMARY KEY ("nodeId", "appId", "appKey"),
CONSTRAINT "NodeMeta_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "Node" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "NodeMeta_appId_fkey" FOREIGN KEY ("appId") REFERENCES "App" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_NodeMeta" ("appId", "appKey", "nodeId", "value") SELECT "appId", "appKey", "nodeId", "value" FROM "NodeMeta";
DROP TABLE "NodeMeta";
ALTER TABLE "new_NodeMeta" RENAME TO "NodeMeta";
CREATE INDEX "NodeMeta_appId_appKey_idx" ON "NodeMeta"("appId", "appKey");
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;