panorama/prisma/migrations/20230418190111_hellosu/migration.sql

76 lines
2.4 KiB
MySQL
Raw Normal View History

2023-03-30 01:56:52 +00:00
-- CreateTable
CREATE TABLE "Node" (
"id" TEXT NOT NULL PRIMARY KEY,
"label" TEXT
);
-- CreateTable
CREATE TABLE "Interface" (
"id" TEXT NOT NULL PRIMARY KEY
);
-- CreateTable
2023-04-18 07:38:22 +00:00
CREATE TABLE "Edge" (
"id" TEXT NOT NULL PRIMARY KEY,
2023-03-30 01:56:52 +00:00
"label" TEXT,
2023-04-18 07:38:22 +00:00
"appId" TEXT NOT NULL,
"appKey" TEXT NOT NULL,
2023-03-30 01:56:52 +00:00
"fromId" TEXT NOT NULL,
"toId" TEXT NOT NULL,
2023-04-18 07:38:22 +00:00
CONSTRAINT "Edge_appId_fkey" FOREIGN KEY ("appId") REFERENCES "App" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "Edge_fromId_fkey" FOREIGN KEY ("fromId") REFERENCES "Node" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "Edge_toId_fkey" FOREIGN KEY ("toId") REFERENCES "Node" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
2023-03-30 01:56:52 +00:00
);
-- CreateTable
CREATE TABLE "NodeMeta" (
"nodeId" TEXT NOT NULL,
"appId" TEXT NOT NULL,
2023-04-18 07:38:22 +00:00
"appKey" TEXT NOT NULL,
2023-03-30 01:56:52 +00:00
"value" BLOB NOT NULL,
2023-04-18 07:38:22 +00:00
PRIMARY KEY ("nodeId", "appId", "appKey"),
2023-03-30 01:56:52 +00:00
CONSTRAINT "NodeMeta_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "Node" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "NodeMeta_appId_fkey" FOREIGN KEY ("appId") REFERENCES "App" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "NodeImplements" (
"nodeId" TEXT NOT NULL,
"interfaceId" TEXT NOT NULL,
PRIMARY KEY ("nodeId", "interfaceId"),
CONSTRAINT "NodeImplements_nodeId_fkey" FOREIGN KEY ("nodeId") REFERENCES "Node" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "NodeImplements_interfaceId_fkey" FOREIGN KEY ("interfaceId") REFERENCES "Interface" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "App" (
"id" TEXT NOT NULL PRIMARY KEY,
"localName" TEXT NOT NULL,
"title" TEXT NOT NULL,
"installed" DATETIME NOT NULL
);
-- CreateTable
CREATE TABLE "Patterns" (
"id" TEXT NOT NULL PRIMARY KEY,
"pattern" TEXT NOT NULL,
2023-04-18 07:38:22 +00:00
"type" TEXT NOT NULL,
2023-03-30 01:56:52 +00:00
"appId" TEXT NOT NULL,
"functionName" TEXT NOT NULL,
CONSTRAINT "Patterns_appId_fkey" FOREIGN KEY ("appId") REFERENCES "App" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
2023-04-18 07:38:22 +00:00
-- CreateIndex
CREATE INDEX "Edge_appId_appKey_idx" ON "Edge"("appId", "appKey");
-- CreateIndex
CREATE UNIQUE INDEX "Edge_fromId_toId_key" ON "Edge"("fromId", "toId");
-- CreateIndex
CREATE INDEX "NodeMeta_appId_appKey_idx" ON "NodeMeta"("appId", "appKey");
2023-03-30 01:56:52 +00:00
-- CreateIndex
CREATE UNIQUE INDEX "App_localName_key" ON "App"("localName");