-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
43 lines (40 loc) · 1.06 KB
/
schema.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
DROP TABLE IF EXISTS "chat";
DROP TABLE IF EXISTS "posts";
DROP TABLE IF EXISTS "users";
CREATE TABLE "users" (
"userId" SERIAL,
"name" TEXT CONSTRAINT "unique_name" UNIQUE,
"password" TEXT,
"username" TEXT CONSTRAINT "unique_username" UNIQUE,
"email" TEXT CONSTRAINT "unique_email" UNIQUE,
"zipcode" INTEGER,
"phone" TEXT,
"profileImage" TEXT,
"genre1" TEXT,
"genre2" TEXT,
"genre3" TEXT,
"createdAt" TIMESTAMP DEFAULT NOW(),
"updatedAt" TIMESTAMP DEFAULT NOW(),
"resetPasswordToken" TEXT,
"resetPasswordExpires" TEXT,
PRIMARY KEY ("userId")
);
CREATE TABLE "posts" (
"postId" SERIAL,
"userId" INTEGER,
"subject" TEXT,
"content" TEXT,
"datePosted" TIMESTAMP DEFAULT NOW(),
"dateUpdated" TIMESTAMP DEFAULT NOW(),
PRIMARY KEY ("postId"),
CONSTRAINT "fk_userId_posts" FOREIGN KEY ("userId") REFERENCES "users" ("userId")
);
CREATE TABLE "chat" (
"chatId" SERIAL,
"userId" INTEGER,
"username" TEXT,
"message" TEXT,
"timeSent" TIMESTAMP DEFAULT NOW(),
PRIMARY KEY ("chatId"),
CONSTRAINT "fk_userId_chat" FOREIGN KEY ("userId") REFERENCES "users" ("userId")
);