-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathschema.sql
More file actions
37 lines (32 loc) · 949 Bytes
/
schema.sql
File metadata and controls
37 lines (32 loc) · 949 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
37
DROP TABLE IF EXISTS hashtags CASCADE;
DROP TABLE IF EXISTS follows CASCADE;
DROP TABLE IF EXISTS blooms CASCADE;
DROP TABLE IF EXISTS users CASCADE;
-- //so I can add sender and count
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,
riginal_sender VARCHAR,
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)
);