panorama/prisma/migrations/20230418213945_meta_cascade_on_delete/migration.sql

19 lines
801 B
MySQL
Raw Normal View History

2023-04-19 01:44:44 +00:00
-- 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;