-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawSQL-pgsql-export-2023-10-17.sql
executable file
·44 lines (44 loc) · 1.43 KB
/
drawSQL-pgsql-export-2023-10-17.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
CREATE TABLE "users"(
"userID" bigserial NOT NULL,
"firstName" VARCHAR(80) NOT NULL,
"lastName" VARCHAR(80) NOT NULL,
"email" VARCHAR(80) NOT NULL,
"admin" BOOLEAN NOT NULL,
"passwordHash" VARCHAR(255) NOT NULL
);
ALTER TABLE
"users" ADD PRIMARY KEY("userID");
ALTER TABLE
"users" ADD CONSTRAINT "users_email_unique" UNIQUE("email");
CREATE TABLE "token"(
"tokenID" bigserial NOT NULL,
"userID" BIGINT NOT NULL,
"sessionToken" VARCHAR(255) NOT NULL,
"tokenExpiration" TIMESTAMP(0) WITH
TIME zone NOT NULL
);
ALTER TABLE
"token" ADD PRIMARY KEY("tokenID");
CREATE TABLE "checkIn"(
"checkInID" bigserial NOT NULL,
"checkInDate" DATE NOT NULL,
"userID" BIGINT NOT NULL,
"checkInTime" TIME(0) WITHOUT TIME ZONE NOT NULL
);
ALTER TABLE
"checkIn" ADD PRIMARY KEY("checkInID");
CREATE TABLE "clubDays"(
"clubDayID" bigserial NOT NULL,
"clubDayDate" DATE NOT NULL,
"clubDayStartTime" TIME(0) WITHOUT TIME ZONE NOT NULL,
"QRCode" VARCHAR(255) NOT NULL,
"clubDayEndTime" BIGINT NOT NULL
);
ALTER TABLE
"clubDays" ADD PRIMARY KEY("clubDayID");
ALTER TABLE
"clubDays" ADD CONSTRAINT "clubdays_clubdaydate_unique" UNIQUE("clubDayDate");
ALTER TABLE
"token" ADD CONSTRAINT "token_userid_foreign" FOREIGN KEY("userID") REFERENCES "users"("userID");
ALTER TABLE
"checkIn" ADD CONSTRAINT "checkin_userid_foreign" FOREIGN KEY("userID") REFERENCES "users"("userID");