-
Notifications
You must be signed in to change notification settings - Fork 0
/
migration.sql
82 lines (67 loc) · 2.54 KB
/
migration.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
-- CreateTable
CREATE TABLE IF NOT EXISTS "User" (
"id" TEXT NOT NULL,
"username" TEXT NOT NULL,
"firstName" TEXT NOT NULL,
"lastName" TEXT NOT NULL,
PRIMARY KEY ("id", "username")
);
-- CreateTable
CREATE TABLE IF NOT EXISTS "Project" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE IF NOT EXISTS "UsersOnProjects" (
"projectName" TEXT NOT NULL,
"userId" TEXT NOT NULL,
PRIMARY KEY ("projectName", "userId"),
CONSTRAINT "UsersOnProjects_userId_username_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "UsersOnProjects_projectName_fkey" FOREIGN KEY ("projectName") REFERENCES "Project" ("name") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE IF NOT EXISTS "Status" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"colour" TEXT NOT NULL,
"treatAsClosed" BOOLEAN NOT NULL,
"projectName" TEXT NOT NULL,
CONSTRAINT "Status_projectName_fkey" FOREIGN KEY ("projectName") REFERENCES "Project" ("name") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE IF NOT EXISTS "Category" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"projectName" TEXT NOT NULL,
CONSTRAINT "Category_projectName_fkey" FOREIGN KEY ("projectName") REFERENCES "Project" ("name") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE IF NOT EXISTS "Type" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"icon" TEXT NOT NULL,
"projectName" TEXT NOT NULL,
CONSTRAINT "Type_projectName_fkey" FOREIGN KEY ("projectName") REFERENCES "Project" ("name") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE IF NOT EXISTS "Priority" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"colour" TEXT NOT NULL,
"projectName" TEXT NOT NULL,
CONSTRAINT "Priority_projectName_fkey" FOREIGN KEY ("projectName") REFERENCES "Project" ("name") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateIndex
CREATE UNIQUE INDEX "User_id_key" ON "User"("id");
-- CreateIndex
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
-- CreateIndex
CREATE UNIQUE INDEX "Project_name_key" ON "Project"("name");
-- CreateIndex
CREATE UNIQUE INDEX "Status_name_key" ON "Status"("name");
-- CreateIndex
CREATE UNIQUE INDEX "Category_name_key" ON "Category"("name");
-- CreateIndex
CREATE UNIQUE INDEX "Type_name_key" ON "Type"("name");
-- CreateIndex
CREATE UNIQUE INDEX "Priority_name_key" ON "Priority"("name");