forked from axolotlcs/coolChat
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathchatDb.sql
More file actions
24 lines (21 loc) · 750 Bytes
/
chatDb.sql
File metadata and controls
24 lines (21 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
CREATE TABLE IF NOT EXISTS users(
"_id" SERIAL PRIMARY KEY,
"username" VARCHAR NOT NULL,
"password" VARCHAR NOT NULL
);
CREATE TABLE IF NOT EXISTS messages (
"_id" SERIAL PRIMARY KEY,
"user_id" INTEGER NOT NULL,
"message" VARCHAR NOT NULL,
"created_at" TIMESTAMP DEFAULT NOW(),
foreign key ("user_id")
references users("_id")
on delete cascade
);
-- coolchat=# ALTER USER student WITH password '12345';
-- coolchat=# GRANT ALL PRIVILEGES ON DATABASE coolchat TO student;
-- psql coolchat -f chatDb.sql
-- coolchat=# GRANT ALL PRIVILEGES ON users TO student;
-- coolchat=# GRANT ALL PRIVILEGES ON messages TO student;
-- GRANT USAGE ON SEQUENCE users__id_seq TO student;
-- GRANT USAGE ON SEQUENCE messages__id_seq TO student;