-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathschema.sql
More file actions
36 lines (32 loc) · 966 Bytes
/
schema.sql
File metadata and controls
36 lines (32 loc) · 966 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
32
33
34
35
36
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
);
CREATE TABLE reblooms (
id BIGSERIAL NOT NULL PRIMARY KEY,
rebloomer_id INT NOT NULL REFERENCES users(id),
original_bloom_id BIGINT NOT NULL REFERENCES blooms(id),
rebloom_timestamp TIMESTAMP NOT NULL,
UNIQUE(rebloomer_id, original_bloom_id)
);
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)
);