-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.sql
30 lines (27 loc) · 882 Bytes
/
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
CREATE TABLE IF NOT EXISTS users (
user_id BIGINT PRIMARY KEY,
join_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
score INTEGER DEFAULT 0,
max_members INTEGER DEFAULT 0,
oldest_message INTEGER DEFAULT 0,
phone_number VARCHAR(16) DEFAULT NULL,
vouched_for INTEGER DEFAULT 0,
external_id TEXT UNIQUE DEFAULT NULL
);
CREATE TABLE IF NOT EXISTS channels (
channel_id BIGINT PRIMARY KEY,
user_id BIGINT REFERENCES users,
members INTEGER,
association_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS vouching (
voucher BIGINT REFERENCES users,
vouched_for BIGINT REFERENCES users,
status VARCHAR(1) DEFAULT 'V',
vouching_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (voucher, vouched_for)
);
CREATE TABLE IF NOT EXISTS api (
token VARCHAR(32) PRIMARY KEY,
quota INTEGER DEFAULT -1
)