generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathschema.sql
More file actions
31 lines (28 loc) · 833 Bytes
/
schema.sql
File metadata and controls
31 lines (28 loc) · 833 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
25
26
27
28
29
30
31
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR NOT NULL,
password_salt BYTEA NOT NULL,
password_scrypt BYTEA NOT NULL,
UNIQUE(username)
);
CREATE TABLE blooms (
id BIGSERIAL NOT NULL PRIMARY KEY,
sender_id INT NOT NULL REFERENCES users(id),
content TEXT NOT NULL,
send_timestamp TIMESTAMP NOT NULL
original_bloom_id BIGINT REFERENCES blooms(id),
original_sender_id INT REFERENCES users(id),
rebloom_count INT DEFAULT 0
);
CREATE TABLE follows (
id SERIAL PRIMARY KEY,
follower INT NOT NULL REFERENCES users(id),
followee INT NOT NULL REFERENCES users(id),
UNIQUE(follower, followee)
);
CREATE TABLE hashtags (
id SERIAL PRIMARY KEY,
hashtag VARCHAR NOT NULL,
bloom_id BIGINT NOT NULL REFERENCES blooms(id),
UNIQUE(hashtag, bloom_id)
);