panorama/src-tauri/migrations/20230612192057_initial.sql
Michael Zhang a6fe682ba0 tauri
2023-06-12 19:13:24 -05:00

68 lines
2 KiB
SQL

-- CreateTable
CREATE TABLE "Node" (
"id" TEXT NOT NULL PRIMARY KEY,
"label" TEXT
);
-- CreateTable
CREATE TABLE "Edge" (
"id" TEXT NOT NULL PRIMARY KEY
);
-- CreateTable
CREATE TABLE "Interface" (
"id" TEXT NOT NULL PRIMARY KEY
);
-- CreateTable
CREATE TABLE "Graph" (
"label" TEXT,
"fromId" TEXT NOT NULL,
"toId" TEXT NOT NULL,
PRIMARY KEY ("fromId", "toId"),
CONSTRAINT "Graph_fromId_fkey" FOREIGN KEY ("fromId") REFERENCES "Node" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "Graph_toId_fkey" FOREIGN KEY ("toId") REFERENCES "Node" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "NodeMeta" (
"nodeId" TEXT NOT NULL,
"appId" TEXT NOT NULL,
"key" TEXT NOT NULL,
"value" BLOB NOT NULL,
PRIMARY KEY ("nodeId", "appId", "key"),
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,
"appId" TEXT NOT NULL,
"functionName" TEXT NOT NULL,
CONSTRAINT "Patterns_appId_fkey" FOREIGN KEY ("appId") REFERENCES "App" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateIndex
CREATE UNIQUE INDEX "App_localName_key" ON "App"("localName");