forked from oslabs-beta/ohana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKlustrSchema.sql
53 lines (43 loc) · 1.42 KB
/
KlustrSchema.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
CREATE TABLE "users" (
"_id" smallserial PRIMARY KEY NOT NULL,
"email" varchar NOT NULL,
"password" varchar NOT NULL,
"first_name" varchar NOT NULL,
"last_name" varchar NOT NULL,
"is_admin" boolean,
"team_id" smallint,
"edit_access" boolean
);
CREATE TABLE "teams" (
"_id" smallserial PRIMARY KEY NOT NULL,
"team_name" varchar NOT NULL,
"team_lead" varchar NOT NULL,
"leader_email" varchar NOT NULL,
"project" varchar
);
CREATE TABLE "namespaces2" (
"_id" smallserial PRIMARY KEY NOT NULL,
"name" varchar NOT NULL,
"team_id" smallint,
"project" varchar,
);
CREATE TABLE "vclusters" (
"_id" smallserial PRIMARY KEY NOT NULL,
"owner_id" smallint NOT NULL,
"team_id" smallint NOT NULL,
"namespace_id" varchar,
"project" varchar
);
-- added clusters table
CREATE TABLE "clusters" (
"_id" smallserial PRIMARY KEY NOT NULL,
"cluster_name" varchar NOT NULL,
"region" varchar,
"zone" varchar
);
ALTER TABLE "users" ADD FOREIGN KEY ("team_id") REFERENCES "teams" ("_id");
-- ALTER TABLE "vclusters" ADD FOREIGN KEY ("namespace_id") REFERENCES "namespaces" ("_id");
ALTER TABLE "vclusters" ADD FOREIGN KEY ("owner_id") REFERENCES "users" ("_id");
ALTER TABLE "namespaces" ADD FOREIGN KEY ("team_id") REFERENCES "teams" ("_id");
-- ALTER TABLE "namespaces" ADD FOREIGN KEY ("cluster_id") REFERENCES "clusters" ("_id");
ALTER TABLE "vclusters" ADD FOREIGN KEY ("team_id") REFERENCES "teams" ("_id");