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

49 lines
1.2 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
threads_ids INT8[],
options JSON
2023-10-24 15:03:00 +03:00
);
CREATE TABLE threads (
thread_id SERIAL8 PRIMARY KEY,
thread_name VARCHAR(32),
posts_ids INT[],
is_locked boolean NOT NULL,
2023-11-04 11:22:29 +03:00
is_pinned boolean NOT NULL,
options VARCHAR(255)
2023-10-24 15:03:00 +03:00
);
CREATE TABLE media (
media_id VARCHAR(22) PRIMARY KEY -- format: ${thread_id}-${media_number}, len(thread_id) = 20, + "-" + len(media_number) = 1 = 22
);
CREATE TABLE posts (
post_id SERIAL8 PRIMARY KEY,
content TEXT NOT NULL,
media_ids VARCHAR(22)[],
is_root BOOL NOT NULL,
date DATE NOT NULL,
internal_id INT NOT NULL, -- id of the post inside of the thread
user_ip CIDR NOT NULL
);
CREATE TABLE admins (
login VARCHAR(16) PRIMARY KEY,
password_hash CHAR(60) NOT NULL,
privelege_name VARCHAR(16) NOT NULL
);
CREATE TABLE priveleges (
privelege_name VARCHAR(16) PRIMARY KEY,
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
);