forked from dachan/dach
1
0
Fork 0
dach/database_schematic.pgsql

53 lines
1.3 KiB
Plaintext
Raw Normal View History

2023-10-24 15:03:00 +03:00
CREATE TABLE boards (
board_id VARCHAR(5) PRIMARY KEY,
board_name VARCHAR(32) NOT NULL,
2023-11-04 11:22:29 +03:00
options JSON
2023-10-24 15:03:00 +03:00
);
CREATE TABLE threads (
2023-11-17 01:17:09 +03:00
board_id VARCHAR(5) NOT NULL,
thread_id BIGINT NOT NULL,
2023-10-24 15:03:00 +03:00
thread_name VARCHAR(32),
2023-11-04 12:00:51 +03:00
posts_ids BIGINT[],
is_locked boolean NOT NULL,
2023-11-04 11:22:29 +03:00
is_pinned boolean NOT NULL,
2023-11-17 01:17:09 +03:00
options VARCHAR(255),
PRIMARY KEY(board_id, thread_id)
2023-10-24 15:03:00 +03:00
);
CREATE TABLE media (
2024-01-14 18:48:04 +03:00
media_id VARCHAR(32) PRIMARY KEY -- format: ${thread_id}-${media_number}.${ext}
2023-10-24 15:03:00 +03:00
);
CREATE TABLE posts (
2023-11-17 01:17:09 +03:00
board_id VARCHAR(5) NOT NULL,
thread_id BIGINT NOT NULL,
post_id BIGINT NOT NULL,
2023-11-16 20:33:38 +03:00
options VARCHAR(255),
2023-10-24 15:03:00 +03:00
content TEXT NOT NULL,
media_ids VARCHAR(22)[],
is_root BOOL NOT NULL,
2023-11-04 14:34:48 +03:00
timestamp TIMESTAMP NOT NULL,
2023-11-17 01:17:09 +03:00
user_ip CIDR NOT NULL,
PRIMARY KEY(board_id, thread_id, post_id)
2023-10-24 15:03:00 +03:00
);
CREATE TABLE admins (
login VARCHAR(16) PRIMARY KEY,
password_hash CHAR(60) NOT NULL,
2024-01-14 18:48:04 +03:00
privilege_name VARCHAR(16) NOT NULL
2023-10-24 15:03:00 +03:00
);
2024-01-14 18:48:04 +03:00
CREATE TABLE privileges (
privilege_name VARCHAR(16) PRIMARY KEY,
2023-10-24 15:03:00 +03:00
access_level INT2 NOT NULL
);
CREATE TABLE bans (
ban_id SERIAL8 PRIMARY KEY,
user_ip CIDR NOT NULL,
duration INT8, -- duration in seconds
reason VARCHAR(255),
date DATE NOT NULL,
admin_issued VARCHAR(16) NOT NULL
);