mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-28 08:06:24 -07:00
Move build sql to devtools, fix capitalisation
This commit is contained in:
parent
82a902ebba
commit
7665b78aff
5 changed files with 410 additions and 398 deletions
|
@ -1,3 +1,5 @@
|
|||
from os import path
|
||||
|
||||
class macro():
|
||||
def __init__(self, macroname, postgres, sqlite, mysql):
|
||||
self.macroname = macroname
|
||||
|
@ -7,10 +9,12 @@ class macro():
|
|||
|
||||
# macros
|
||||
macros = [
|
||||
macro("serial pk", "bigserial PRIMARY KEY", "INTEGER PRIMARY KEY AUTOINCREMENT", "bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY"),
|
||||
macro("fk to serial", "bigint", "INTEGER", "bigint")
|
||||
macro("serial pk", "BIGSERIAL PRIMARY KEY", "INTEGER PRIMARY KEY AUTOINCREMENT", "BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY"),
|
||||
macro("fk to serial", "BIGINT", "INTEGER", "BIGINT")
|
||||
]
|
||||
masterfile = open("initdb_master.sql").read()
|
||||
masterfileIn = open(path.join("..", "initdb_master.sql"), 'r')
|
||||
masterfile = masterfileIn.read()
|
||||
masterfileIn.close()
|
||||
|
||||
postgresProcessed = masterfile
|
||||
sqliteProcessed = masterfile
|
||||
|
@ -30,9 +34,17 @@ error = hasError(postgresProcessed)
|
|||
error = error or hasError(mysqlProcessed)
|
||||
error = error or hasError(sqliteProcessed)
|
||||
|
||||
open("initdb_postgres.sql", 'w').write(postgresProcessed)
|
||||
open("initdb_mysql.sql", 'w').write(mysqlProcessed)
|
||||
open("initdb_sqlite3.sql", 'w').write(sqliteProcessed)
|
||||
i = open(path.join("..", "initdb_postgres.sql"), 'w')
|
||||
i.write(postgresProcessed)
|
||||
i.close()
|
||||
|
||||
i = open(path.join("..", "initdb_mysql.sql"), 'w')
|
||||
i.write(mysqlProcessed)
|
||||
i.close()
|
||||
|
||||
i = open(path.join("..", "initdb_sqlite3.sql"), 'w')
|
||||
i.write(sqliteProcessed)
|
||||
i.close()
|
||||
|
||||
if error:
|
||||
input("Error processing macros, files still contain curly braces (might be in comments?), press any key to continue")
|
|
@ -5,7 +5,7 @@
|
|||
-- Database version: 1
|
||||
|
||||
CREATE TABLE database_version(
|
||||
version int NOT NULL
|
||||
version INT NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO database_version(version)
|
||||
|
@ -20,11 +20,11 @@ CREATE TABLE sections(
|
|||
UNIQUE(position)
|
||||
);
|
||||
|
||||
create table boards(
|
||||
CREATE TABLE boards(
|
||||
id {serial pk},
|
||||
section_id {fk to serial} NOT NULL,
|
||||
uri text NOT NULL,
|
||||
dir varchar(45) NOT NULL,
|
||||
uri TEXT NOT NULL,
|
||||
dir VARCHAR(45) NOT NULL,
|
||||
navbar_position SMALLINT NOT NULL,
|
||||
title VARCHAR(45) NOT NULL,
|
||||
subtitle VARCHAR(64) NOT NULL,
|
||||
|
@ -32,231 +32,231 @@ create table boards(
|
|||
max_file_size SMALLINT NOT NULL,
|
||||
max_threads SMALLINT NOT NULL,
|
||||
default_style VARCHAR(45) NOT NULL,
|
||||
locked bool NOT NULL,
|
||||
created_at timestamp NOT NULL,
|
||||
locked BOOL NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
anonymous_name VARCHAR(45) NOT NULL DEFAULT 'Anonymous',
|
||||
force_anonymous bool NOT NULL,
|
||||
force_anonymous BOOL NOT NULL,
|
||||
autosage_after SMALLINT NOT NULL,
|
||||
no_images_after SMALLINT NOT NULL,
|
||||
max_message_length SMALLINT NOT NULL,
|
||||
min_message_length SMALLINT NOT NULL,
|
||||
allow_embeds bool NOT NULL,
|
||||
redictect_to_thread bool NOT NULL,
|
||||
require_file bool NOT NULL,
|
||||
enable_catalog bool NOT NULL,
|
||||
allow_embeds BOOL NOT NULL,
|
||||
redictect_to_thread BOOL NOT NULL,
|
||||
require_file BOOL NOT NULL,
|
||||
enable_catalog BOOL NOT NULL,
|
||||
FOREIGN KEY(section_id) REFERENCES sections(id),
|
||||
UNIQUE(dir),
|
||||
UNIQUE(uri),
|
||||
UNIQUE(navbar_position)
|
||||
);
|
||||
|
||||
create table threads(
|
||||
CREATE TABLE threads(
|
||||
id {serial pk},
|
||||
board_id {fk to serial} NOT NULL,
|
||||
locked bool NOT NULL,
|
||||
stickied bool NOT NULL,
|
||||
anchored bool NOT NULL,
|
||||
cyclical bool NOT NULL,
|
||||
last_bump timestamp NOT NULL,
|
||||
deleted_at timestamp NOT NULL,
|
||||
is_deleted bool NOT NULL,
|
||||
locked BOOL NOT NULL,
|
||||
stickied BOOL NOT NULL,
|
||||
anchored BOOL NOT NULL,
|
||||
cyclical BOOL NOT NULL,
|
||||
last_bump TIMESTAMP NOT NULL,
|
||||
deleted_at TIMESTAMP NOT NULL,
|
||||
is_deleted BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id)
|
||||
);
|
||||
|
||||
CREATE INDEX thread_deleted_index ON threads(is_deleted);
|
||||
|
||||
create table posts(
|
||||
CREATE TABLE posts(
|
||||
id {serial pk},
|
||||
thread_id {fk to serial} NOT NULL,
|
||||
is_top_post bool NOT NULL,
|
||||
ip int NOT NULL,
|
||||
is_top_post BOOL NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
created_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
tripcode VARCHAR(10) NOT NULL,
|
||||
is_role_signature bool NOT NULL DEFAULT FALSE,
|
||||
is_role_signature BOOL NOT NULL DEFAULT FALSE,
|
||||
email VARCHAR(50) NOT NULL,
|
||||
subject VARCHAR(100) NOT NULL,
|
||||
message text NOT NULL,
|
||||
message_raw text NOT NULL,
|
||||
password text NOT NULL,
|
||||
deleted_at timestamp NOT NULL,
|
||||
is_deleted bool NOT NULL,
|
||||
banned_message text,
|
||||
message TEXT NOT NULL,
|
||||
message_raw TEXT NOT NULL,
|
||||
password TEXT NOT NULL,
|
||||
deleted_at TIMESTAMP NOT NULL,
|
||||
is_deleted BOOL NOT NULL,
|
||||
banned_message TEXT,
|
||||
FOREIGN KEY(thread_id) REFERENCES threads(id)
|
||||
);
|
||||
|
||||
CREATE INDEX top_post_index ON posts(is_top_post);
|
||||
|
||||
create table files(
|
||||
CREATE TABLE files(
|
||||
id {serial pk},
|
||||
post_id {fk to serial} NOT NULL,
|
||||
file_order int NOT NULL,
|
||||
file_order INT NOT NULL,
|
||||
original_filename VARCHAR(255) NOT NULL,
|
||||
filename VARCHAR(45) NOT NULL,
|
||||
checksum int NOT NULL,
|
||||
file_size int NOT NULL,
|
||||
is_spoilered bool NOT NULL,
|
||||
checksum INT NOT NULL,
|
||||
file_size INT NOT NULL,
|
||||
is_spoilered BOOL NOT NULL,
|
||||
FOREIGN KEY(post_id) REFERENCES posts(id),
|
||||
UNIQUE(post_id, file_order)
|
||||
);
|
||||
|
||||
create table staff(
|
||||
CREATE TABLE staff(
|
||||
id {serial pk},
|
||||
username VARCHAR(45) NOT NULL,
|
||||
password_checksum VARCHAR(120) NOT NULL,
|
||||
global_rank int,
|
||||
global_rank INT,
|
||||
added_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
last_login TIMESTAMP NOT NULL,
|
||||
is_active bool NOT NULL DEFAULT TRUE,
|
||||
is_active BOOL NOT NULL DEFAULT TRUE,
|
||||
UNIQUE(username)
|
||||
);
|
||||
|
||||
create table sessions(
|
||||
CREATE TABLE sessions(
|
||||
id {serial pk},
|
||||
staff_id {fk to serial} NOT NULL,
|
||||
expires TIMESTAMP NOT NULL,
|
||||
data varchar(45) NOT NULL,
|
||||
data VARCHAR(45) NOT NULL,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table board_staff(
|
||||
CREATE TABLE board_staff(
|
||||
board_id {fk to serial} NOT NULL,
|
||||
staff_id {fk to serial} NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table announcements(
|
||||
CREATE TABLE announcements(
|
||||
id {serial pk},
|
||||
staff_id {fk to serial} NOT NULL,
|
||||
subject VARCHAR(45) NOT NULL,
|
||||
message text NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table ip_ban(
|
||||
CREATE TABLE ip_ban(
|
||||
id {serial pk},
|
||||
staff_id {fk to serial} NOT NULL,
|
||||
board_id {fk to serial} NOT NULL,
|
||||
banned_for_post_id {fk to serial} NOT NULL,
|
||||
copy_post_text text NOT NULL,
|
||||
is_active bool NOT NULL,
|
||||
ip int NOT NULL,
|
||||
copy_post_text TEXT NOT NULL,
|
||||
is_active BOOL NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL,
|
||||
appeal_at TIMESTAMP NOT NULL,
|
||||
expires_at TIMESTAMP NOT NULL,
|
||||
permanent bool NOT NULL,
|
||||
permanent BOOL NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
message text NOT NULL,
|
||||
can_appeal bool NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
can_appeal BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(banned_for_post_id) REFERENCES posts(id)
|
||||
);
|
||||
|
||||
create table ip_ban_audit(
|
||||
CREATE TABLE ip_ban_audit(
|
||||
ip_ban_id {fk to serial} NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
staff_id {fk to serial} NOT NULL,
|
||||
is_active bool NOT NULL,
|
||||
is_active BOOL NOT NULL,
|
||||
expires_at TIMESTAMP NOT NULL,
|
||||
appeal_at TIMESTAMP NOT NULL,
|
||||
permanent bool NOT NULL,
|
||||
permanent BOOL NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
message text NOT NULL,
|
||||
can_appeal bool NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
can_appeal BOOL NOT NULL,
|
||||
PRIMARY KEY(ip_ban_id, timestamp),
|
||||
FOREIGN KEY(ip_ban_id) REFERENCES ip_ban(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table ip_ban_appeals(
|
||||
CREATE TABLE ip_ban_appeals(
|
||||
id {serial pk},
|
||||
staff_id {fk to serial},
|
||||
ip_ban_id {fk to serial} NOT NULL,
|
||||
appeal_text text NOT NULL,
|
||||
staff_response text,
|
||||
is_denied bool NOT NULL,
|
||||
appeal_text TEXT NOT NULL,
|
||||
staff_response TEXT,
|
||||
is_denied BOOL NOT NULL,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(ip_ban_id) REFERENCES ip_ban(id)
|
||||
);
|
||||
|
||||
create table ip_ban_appeals_audit(
|
||||
CREATE TABLE ip_ban_appeals_audit(
|
||||
appeal_id {fk to serial} NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
staff_id {fk to serial},
|
||||
appeal_text text NOT NULL,
|
||||
staff_response text,
|
||||
is_denied bool NOT NULL,
|
||||
appeal_text TEXT NOT NULL,
|
||||
staff_response TEXT,
|
||||
is_denied BOOL NOT NULL,
|
||||
PRIMARY KEY(appeal_id, timestamp),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(appeal_id) REFERENCES ip_ban_appeals(id)
|
||||
);
|
||||
|
||||
create table reports(
|
||||
CREATE TABLE reports(
|
||||
id {serial pk},
|
||||
handled_by_staff_id {fk to serial},
|
||||
post_id {fk to serial} NOT NULL,
|
||||
ip int NOT NULL,
|
||||
reason text NOT NULL,
|
||||
is_cleared bool NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
reason TEXT NOT NULL,
|
||||
is_cleared BOOL NOT NULL,
|
||||
FOREIGN KEY(handled_by_staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(post_id) REFERENCES posts(id)
|
||||
);
|
||||
|
||||
create table reports_audit(
|
||||
CREATE TABLE reports_audit(
|
||||
report_id {fk to serial} NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
handled_by_staff_id {fk to serial},
|
||||
is_cleared bool NOT NULL,
|
||||
is_cleared BOOL NOT NULL,
|
||||
FOREIGN KEY(handled_by_staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(report_id) REFERENCES reports(id)
|
||||
);
|
||||
|
||||
create table filename_ban(
|
||||
CREATE TABLE filename_ban(
|
||||
id {serial pk},
|
||||
board_id {fk to serial},
|
||||
staff_id {fk to serial} NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
filename VARCHAR(255) NOT NULL,
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table username_ban(
|
||||
CREATE TABLE username_ban(
|
||||
id {serial pk},
|
||||
board_id {fk to serial},
|
||||
staff_id {fk to serial} NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
username VARCHAR(255) NOT NULL,
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table file_ban(
|
||||
CREATE TABLE file_ban(
|
||||
id {serial pk},
|
||||
board_id {fk to serial},
|
||||
staff_id {fk to serial} NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
checksum int NOT NULL,
|
||||
checksum INT NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table wordfilters(
|
||||
CREATE TABLE wordfilters(
|
||||
id {serial pk},
|
||||
board_id {fk to serial},
|
||||
staff_id {fk to serial} NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
search VARCHAR(75) NOT NULL CHECK (search <> ''),
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
change_to VARCHAR(75) NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
|
|
240
initdb_mysql.sql
240
initdb_mysql.sql
|
@ -5,14 +5,14 @@
|
|||
-- Database version: 1
|
||||
|
||||
CREATE TABLE database_version(
|
||||
version int NOT NULL
|
||||
version INT NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO database_version(version)
|
||||
VALUES(1);
|
||||
|
||||
CREATE TABLE sections(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
abbreviation TEXT NOT NULL,
|
||||
position SMALLINT NOT NULL,
|
||||
|
@ -20,11 +20,11 @@ CREATE TABLE sections(
|
|||
UNIQUE(position)
|
||||
);
|
||||
|
||||
create table boards(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
section_id bigint NOT NULL,
|
||||
uri text NOT NULL,
|
||||
dir varchar(45) NOT NULL,
|
||||
CREATE TABLE boards(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
section_id BIGINT NOT NULL,
|
||||
uri TEXT NOT NULL,
|
||||
dir VARCHAR(45) NOT NULL,
|
||||
navbar_position SMALLINT NOT NULL,
|
||||
title VARCHAR(45) NOT NULL,
|
||||
subtitle VARCHAR(64) NOT NULL,
|
||||
|
@ -32,231 +32,231 @@ create table boards(
|
|||
max_file_size SMALLINT NOT NULL,
|
||||
max_threads SMALLINT NOT NULL,
|
||||
default_style VARCHAR(45) NOT NULL,
|
||||
locked bool NOT NULL,
|
||||
created_at timestamp NOT NULL,
|
||||
locked BOOL NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
anonymous_name VARCHAR(45) NOT NULL DEFAULT 'Anonymous',
|
||||
force_anonymous bool NOT NULL,
|
||||
force_anonymous BOOL NOT NULL,
|
||||
autosage_after SMALLINT NOT NULL,
|
||||
no_images_after SMALLINT NOT NULL,
|
||||
max_message_length SMALLINT NOT NULL,
|
||||
min_message_length SMALLINT NOT NULL,
|
||||
allow_embeds bool NOT NULL,
|
||||
redictect_to_thread bool NOT NULL,
|
||||
require_file bool NOT NULL,
|
||||
enable_catalog bool NOT NULL,
|
||||
allow_embeds BOOL NOT NULL,
|
||||
redictect_to_thread BOOL NOT NULL,
|
||||
require_file BOOL NOT NULL,
|
||||
enable_catalog BOOL NOT NULL,
|
||||
FOREIGN KEY(section_id) REFERENCES sections(id),
|
||||
UNIQUE(dir),
|
||||
UNIQUE(uri),
|
||||
UNIQUE(navbar_position)
|
||||
);
|
||||
|
||||
create table threads(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
board_id bigint NOT NULL,
|
||||
locked bool NOT NULL,
|
||||
stickied bool NOT NULL,
|
||||
anchored bool NOT NULL,
|
||||
cyclical bool NOT NULL,
|
||||
last_bump timestamp NOT NULL,
|
||||
deleted_at timestamp NOT NULL,
|
||||
is_deleted bool NOT NULL,
|
||||
CREATE TABLE threads(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
board_id BIGINT NOT NULL,
|
||||
locked BOOL NOT NULL,
|
||||
stickied BOOL NOT NULL,
|
||||
anchored BOOL NOT NULL,
|
||||
cyclical BOOL NOT NULL,
|
||||
last_bump TIMESTAMP NOT NULL,
|
||||
deleted_at TIMESTAMP NOT NULL,
|
||||
is_deleted BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id)
|
||||
);
|
||||
|
||||
CREATE INDEX thread_deleted_index ON threads(is_deleted);
|
||||
|
||||
create table posts(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
thread_id bigint NOT NULL,
|
||||
is_top_post bool NOT NULL,
|
||||
ip int NOT NULL,
|
||||
CREATE TABLE posts(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
thread_id BIGINT NOT NULL,
|
||||
is_top_post BOOL NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
created_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
tripcode VARCHAR(10) NOT NULL,
|
||||
is_role_signature bool NOT NULL DEFAULT FALSE,
|
||||
is_role_signature BOOL NOT NULL DEFAULT FALSE,
|
||||
email VARCHAR(50) NOT NULL,
|
||||
subject VARCHAR(100) NOT NULL,
|
||||
message text NOT NULL,
|
||||
message_raw text NOT NULL,
|
||||
password text NOT NULL,
|
||||
deleted_at timestamp NOT NULL,
|
||||
is_deleted bool NOT NULL,
|
||||
banned_message text,
|
||||
message TEXT NOT NULL,
|
||||
message_raw TEXT NOT NULL,
|
||||
password TEXT NOT NULL,
|
||||
deleted_at TIMESTAMP NOT NULL,
|
||||
is_deleted BOOL NOT NULL,
|
||||
banned_message TEXT,
|
||||
FOREIGN KEY(thread_id) REFERENCES threads(id)
|
||||
);
|
||||
|
||||
CREATE INDEX top_post_index ON posts(is_top_post);
|
||||
|
||||
create table files(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
post_id bigint NOT NULL,
|
||||
file_order int NOT NULL,
|
||||
CREATE TABLE files(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
post_id BIGINT NOT NULL,
|
||||
file_order INT NOT NULL,
|
||||
original_filename VARCHAR(255) NOT NULL,
|
||||
filename VARCHAR(45) NOT NULL,
|
||||
checksum int NOT NULL,
|
||||
file_size int NOT NULL,
|
||||
is_spoilered bool NOT NULL,
|
||||
checksum INT NOT NULL,
|
||||
file_size INT NOT NULL,
|
||||
is_spoilered BOOL NOT NULL,
|
||||
FOREIGN KEY(post_id) REFERENCES posts(id),
|
||||
UNIQUE(post_id, file_order)
|
||||
);
|
||||
|
||||
create table staff(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
CREATE TABLE staff(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
username VARCHAR(45) NOT NULL,
|
||||
password_checksum VARCHAR(120) NOT NULL,
|
||||
global_rank int,
|
||||
global_rank INT,
|
||||
added_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
last_login TIMESTAMP NOT NULL,
|
||||
is_active bool NOT NULL DEFAULT TRUE,
|
||||
is_active BOOL NOT NULL DEFAULT TRUE,
|
||||
UNIQUE(username)
|
||||
);
|
||||
|
||||
create table sessions(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE sessions(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
staff_id BIGINT NOT NULL,
|
||||
expires TIMESTAMP NOT NULL,
|
||||
data varchar(45) NOT NULL,
|
||||
data VARCHAR(45) NOT NULL,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table board_staff(
|
||||
board_id bigint NOT NULL,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE board_staff(
|
||||
board_id BIGINT NOT NULL,
|
||||
staff_id BIGINT NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table announcements(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE announcements(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
staff_id BIGINT NOT NULL,
|
||||
subject VARCHAR(45) NOT NULL,
|
||||
message text NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table ip_ban(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
staff_id bigint NOT NULL,
|
||||
board_id bigint NOT NULL,
|
||||
banned_for_post_id bigint NOT NULL,
|
||||
copy_post_text text NOT NULL,
|
||||
is_active bool NOT NULL,
|
||||
ip int NOT NULL,
|
||||
CREATE TABLE ip_ban(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
staff_id BIGINT NOT NULL,
|
||||
board_id BIGINT NOT NULL,
|
||||
banned_for_post_id BIGINT NOT NULL,
|
||||
copy_post_text TEXT NOT NULL,
|
||||
is_active BOOL NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL,
|
||||
appeal_at TIMESTAMP NOT NULL,
|
||||
expires_at TIMESTAMP NOT NULL,
|
||||
permanent bool NOT NULL,
|
||||
permanent BOOL NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
message text NOT NULL,
|
||||
can_appeal bool NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
can_appeal BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(banned_for_post_id) REFERENCES posts(id)
|
||||
);
|
||||
|
||||
create table ip_ban_audit(
|
||||
ip_ban_id bigint NOT NULL,
|
||||
CREATE TABLE ip_ban_audit(
|
||||
ip_ban_id BIGINT NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
staff_id bigint NOT NULL,
|
||||
is_active bool NOT NULL,
|
||||
staff_id BIGINT NOT NULL,
|
||||
is_active BOOL NOT NULL,
|
||||
expires_at TIMESTAMP NOT NULL,
|
||||
appeal_at TIMESTAMP NOT NULL,
|
||||
permanent bool NOT NULL,
|
||||
permanent BOOL NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
message text NOT NULL,
|
||||
can_appeal bool NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
can_appeal BOOL NOT NULL,
|
||||
PRIMARY KEY(ip_ban_id, timestamp),
|
||||
FOREIGN KEY(ip_ban_id) REFERENCES ip_ban(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table ip_ban_appeals(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
staff_id bigint,
|
||||
ip_ban_id bigint NOT NULL,
|
||||
appeal_text text NOT NULL,
|
||||
staff_response text,
|
||||
is_denied bool NOT NULL,
|
||||
CREATE TABLE ip_ban_appeals(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
staff_id BIGINT,
|
||||
ip_ban_id BIGINT NOT NULL,
|
||||
appeal_text TEXT NOT NULL,
|
||||
staff_response TEXT,
|
||||
is_denied BOOL NOT NULL,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(ip_ban_id) REFERENCES ip_ban(id)
|
||||
);
|
||||
|
||||
create table ip_ban_appeals_audit(
|
||||
appeal_id bigint NOT NULL,
|
||||
CREATE TABLE ip_ban_appeals_audit(
|
||||
appeal_id BIGINT NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
staff_id bigint,
|
||||
appeal_text text NOT NULL,
|
||||
staff_response text,
|
||||
is_denied bool NOT NULL,
|
||||
staff_id BIGINT,
|
||||
appeal_text TEXT NOT NULL,
|
||||
staff_response TEXT,
|
||||
is_denied BOOL NOT NULL,
|
||||
PRIMARY KEY(appeal_id, timestamp),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(appeal_id) REFERENCES ip_ban_appeals(id)
|
||||
);
|
||||
|
||||
create table reports(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
handled_by_staff_id bigint,
|
||||
post_id bigint NOT NULL,
|
||||
ip int NOT NULL,
|
||||
reason text NOT NULL,
|
||||
is_cleared bool NOT NULL,
|
||||
CREATE TABLE reports(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
handled_by_staff_id BIGINT,
|
||||
post_id BIGINT NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
reason TEXT NOT NULL,
|
||||
is_cleared BOOL NOT NULL,
|
||||
FOREIGN KEY(handled_by_staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(post_id) REFERENCES posts(id)
|
||||
);
|
||||
|
||||
create table reports_audit(
|
||||
report_id bigint NOT NULL,
|
||||
CREATE TABLE reports_audit(
|
||||
report_id BIGINT NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
handled_by_staff_id bigint,
|
||||
is_cleared bool NOT NULL,
|
||||
handled_by_staff_id BIGINT,
|
||||
is_cleared BOOL NOT NULL,
|
||||
FOREIGN KEY(handled_by_staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(report_id) REFERENCES reports(id)
|
||||
);
|
||||
|
||||
create table filename_ban(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
board_id bigint,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE filename_ban(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
board_id BIGINT,
|
||||
staff_id BIGINT NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
filename VARCHAR(255) NOT NULL,
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table username_ban(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
board_id bigint,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE username_ban(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
board_id BIGINT,
|
||||
staff_id BIGINT NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
username VARCHAR(255) NOT NULL,
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table file_ban(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
board_id bigint,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE file_ban(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
board_id BIGINT,
|
||||
staff_id BIGINT NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
checksum int NOT NULL,
|
||||
checksum INT NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table wordfilters(
|
||||
id bigint NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
board_id bigint,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE wordfilters(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
|
||||
board_id BIGINT,
|
||||
staff_id BIGINT NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
search VARCHAR(75) NOT NULL CHECK (search <> ''),
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
change_to VARCHAR(75) NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
-- Database version: 1
|
||||
|
||||
CREATE TABLE database_version(
|
||||
version int NOT NULL
|
||||
version INT NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO database_version(version)
|
||||
VALUES(1);
|
||||
|
||||
CREATE TABLE sections(
|
||||
id bigserial PRIMARY KEY,
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
abbreviation TEXT NOT NULL,
|
||||
position SMALLINT NOT NULL,
|
||||
|
@ -20,11 +20,11 @@ CREATE TABLE sections(
|
|||
UNIQUE(position)
|
||||
);
|
||||
|
||||
create table boards(
|
||||
id bigserial PRIMARY KEY,
|
||||
section_id bigint NOT NULL,
|
||||
uri text NOT NULL,
|
||||
dir varchar(45) NOT NULL,
|
||||
CREATE TABLE boards(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
section_id BIGINT NOT NULL,
|
||||
uri TEXT NOT NULL,
|
||||
dir VARCHAR(45) NOT NULL,
|
||||
navbar_position SMALLINT NOT NULL,
|
||||
title VARCHAR(45) NOT NULL,
|
||||
subtitle VARCHAR(64) NOT NULL,
|
||||
|
@ -32,231 +32,231 @@ create table boards(
|
|||
max_file_size SMALLINT NOT NULL,
|
||||
max_threads SMALLINT NOT NULL,
|
||||
default_style VARCHAR(45) NOT NULL,
|
||||
locked bool NOT NULL,
|
||||
created_at timestamp NOT NULL,
|
||||
locked BOOL NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
anonymous_name VARCHAR(45) NOT NULL DEFAULT 'Anonymous',
|
||||
force_anonymous bool NOT NULL,
|
||||
force_anonymous BOOL NOT NULL,
|
||||
autosage_after SMALLINT NOT NULL,
|
||||
no_images_after SMALLINT NOT NULL,
|
||||
max_message_length SMALLINT NOT NULL,
|
||||
min_message_length SMALLINT NOT NULL,
|
||||
allow_embeds bool NOT NULL,
|
||||
redictect_to_thread bool NOT NULL,
|
||||
require_file bool NOT NULL,
|
||||
enable_catalog bool NOT NULL,
|
||||
allow_embeds BOOL NOT NULL,
|
||||
redictect_to_thread BOOL NOT NULL,
|
||||
require_file BOOL NOT NULL,
|
||||
enable_catalog BOOL NOT NULL,
|
||||
FOREIGN KEY(section_id) REFERENCES sections(id),
|
||||
UNIQUE(dir),
|
||||
UNIQUE(uri),
|
||||
UNIQUE(navbar_position)
|
||||
);
|
||||
|
||||
create table threads(
|
||||
id bigserial PRIMARY KEY,
|
||||
board_id bigint NOT NULL,
|
||||
locked bool NOT NULL,
|
||||
stickied bool NOT NULL,
|
||||
anchored bool NOT NULL,
|
||||
cyclical bool NOT NULL,
|
||||
last_bump timestamp NOT NULL,
|
||||
deleted_at timestamp NOT NULL,
|
||||
is_deleted bool NOT NULL,
|
||||
CREATE TABLE threads(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
board_id BIGINT NOT NULL,
|
||||
locked BOOL NOT NULL,
|
||||
stickied BOOL NOT NULL,
|
||||
anchored BOOL NOT NULL,
|
||||
cyclical BOOL NOT NULL,
|
||||
last_bump TIMESTAMP NOT NULL,
|
||||
deleted_at TIMESTAMP NOT NULL,
|
||||
is_deleted BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id)
|
||||
);
|
||||
|
||||
CREATE INDEX thread_deleted_index ON threads(is_deleted);
|
||||
|
||||
create table posts(
|
||||
id bigserial PRIMARY KEY,
|
||||
thread_id bigint NOT NULL,
|
||||
is_top_post bool NOT NULL,
|
||||
ip int NOT NULL,
|
||||
CREATE TABLE posts(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
thread_id BIGINT NOT NULL,
|
||||
is_top_post BOOL NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
created_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
tripcode VARCHAR(10) NOT NULL,
|
||||
is_role_signature bool NOT NULL DEFAULT FALSE,
|
||||
is_role_signature BOOL NOT NULL DEFAULT FALSE,
|
||||
email VARCHAR(50) NOT NULL,
|
||||
subject VARCHAR(100) NOT NULL,
|
||||
message text NOT NULL,
|
||||
message_raw text NOT NULL,
|
||||
password text NOT NULL,
|
||||
deleted_at timestamp NOT NULL,
|
||||
is_deleted bool NOT NULL,
|
||||
banned_message text,
|
||||
message TEXT NOT NULL,
|
||||
message_raw TEXT NOT NULL,
|
||||
password TEXT NOT NULL,
|
||||
deleted_at TIMESTAMP NOT NULL,
|
||||
is_deleted BOOL NOT NULL,
|
||||
banned_message TEXT,
|
||||
FOREIGN KEY(thread_id) REFERENCES threads(id)
|
||||
);
|
||||
|
||||
CREATE INDEX top_post_index ON posts(is_top_post);
|
||||
|
||||
create table files(
|
||||
id bigserial PRIMARY KEY,
|
||||
post_id bigint NOT NULL,
|
||||
file_order int NOT NULL,
|
||||
CREATE TABLE files(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
post_id BIGINT NOT NULL,
|
||||
file_order INT NOT NULL,
|
||||
original_filename VARCHAR(255) NOT NULL,
|
||||
filename VARCHAR(45) NOT NULL,
|
||||
checksum int NOT NULL,
|
||||
file_size int NOT NULL,
|
||||
is_spoilered bool NOT NULL,
|
||||
checksum INT NOT NULL,
|
||||
file_size INT NOT NULL,
|
||||
is_spoilered BOOL NOT NULL,
|
||||
FOREIGN KEY(post_id) REFERENCES posts(id),
|
||||
UNIQUE(post_id, file_order)
|
||||
);
|
||||
|
||||
create table staff(
|
||||
id bigserial PRIMARY KEY,
|
||||
CREATE TABLE staff(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
username VARCHAR(45) NOT NULL,
|
||||
password_checksum VARCHAR(120) NOT NULL,
|
||||
global_rank int,
|
||||
global_rank INT,
|
||||
added_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
last_login TIMESTAMP NOT NULL,
|
||||
is_active bool NOT NULL DEFAULT TRUE,
|
||||
is_active BOOL NOT NULL DEFAULT TRUE,
|
||||
UNIQUE(username)
|
||||
);
|
||||
|
||||
create table sessions(
|
||||
id bigserial PRIMARY KEY,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE sessions(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
staff_id BIGINT NOT NULL,
|
||||
expires TIMESTAMP NOT NULL,
|
||||
data varchar(45) NOT NULL,
|
||||
data VARCHAR(45) NOT NULL,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table board_staff(
|
||||
board_id bigint NOT NULL,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE board_staff(
|
||||
board_id BIGINT NOT NULL,
|
||||
staff_id BIGINT NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table announcements(
|
||||
id bigserial PRIMARY KEY,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE announcements(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
staff_id BIGINT NOT NULL,
|
||||
subject VARCHAR(45) NOT NULL,
|
||||
message text NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table ip_ban(
|
||||
id bigserial PRIMARY KEY,
|
||||
staff_id bigint NOT NULL,
|
||||
board_id bigint NOT NULL,
|
||||
banned_for_post_id bigint NOT NULL,
|
||||
copy_post_text text NOT NULL,
|
||||
is_active bool NOT NULL,
|
||||
ip int NOT NULL,
|
||||
CREATE TABLE ip_ban(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
staff_id BIGINT NOT NULL,
|
||||
board_id BIGINT NOT NULL,
|
||||
banned_for_post_id BIGINT NOT NULL,
|
||||
copy_post_text TEXT NOT NULL,
|
||||
is_active BOOL NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL,
|
||||
appeal_at TIMESTAMP NOT NULL,
|
||||
expires_at TIMESTAMP NOT NULL,
|
||||
permanent bool NOT NULL,
|
||||
permanent BOOL NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
message text NOT NULL,
|
||||
can_appeal bool NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
can_appeal BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(banned_for_post_id) REFERENCES posts(id)
|
||||
);
|
||||
|
||||
create table ip_ban_audit(
|
||||
ip_ban_id bigint NOT NULL,
|
||||
CREATE TABLE ip_ban_audit(
|
||||
ip_ban_id BIGINT NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
staff_id bigint NOT NULL,
|
||||
is_active bool NOT NULL,
|
||||
staff_id BIGINT NOT NULL,
|
||||
is_active BOOL NOT NULL,
|
||||
expires_at TIMESTAMP NOT NULL,
|
||||
appeal_at TIMESTAMP NOT NULL,
|
||||
permanent bool NOT NULL,
|
||||
permanent BOOL NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
message text NOT NULL,
|
||||
can_appeal bool NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
can_appeal BOOL NOT NULL,
|
||||
PRIMARY KEY(ip_ban_id, timestamp),
|
||||
FOREIGN KEY(ip_ban_id) REFERENCES ip_ban(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table ip_ban_appeals(
|
||||
id bigserial PRIMARY KEY,
|
||||
staff_id bigint,
|
||||
ip_ban_id bigint NOT NULL,
|
||||
appeal_text text NOT NULL,
|
||||
staff_response text,
|
||||
is_denied bool NOT NULL,
|
||||
CREATE TABLE ip_ban_appeals(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
staff_id BIGINT,
|
||||
ip_ban_id BIGINT NOT NULL,
|
||||
appeal_text TEXT NOT NULL,
|
||||
staff_response TEXT,
|
||||
is_denied BOOL NOT NULL,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(ip_ban_id) REFERENCES ip_ban(id)
|
||||
);
|
||||
|
||||
create table ip_ban_appeals_audit(
|
||||
appeal_id bigint NOT NULL,
|
||||
CREATE TABLE ip_ban_appeals_audit(
|
||||
appeal_id BIGINT NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
staff_id bigint,
|
||||
appeal_text text NOT NULL,
|
||||
staff_response text,
|
||||
is_denied bool NOT NULL,
|
||||
staff_id BIGINT,
|
||||
appeal_text TEXT NOT NULL,
|
||||
staff_response TEXT,
|
||||
is_denied BOOL NOT NULL,
|
||||
PRIMARY KEY(appeal_id, timestamp),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(appeal_id) REFERENCES ip_ban_appeals(id)
|
||||
);
|
||||
|
||||
create table reports(
|
||||
id bigserial PRIMARY KEY,
|
||||
handled_by_staff_id bigint,
|
||||
post_id bigint NOT NULL,
|
||||
ip int NOT NULL,
|
||||
reason text NOT NULL,
|
||||
is_cleared bool NOT NULL,
|
||||
CREATE TABLE reports(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
handled_by_staff_id BIGINT,
|
||||
post_id BIGINT NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
reason TEXT NOT NULL,
|
||||
is_cleared BOOL NOT NULL,
|
||||
FOREIGN KEY(handled_by_staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(post_id) REFERENCES posts(id)
|
||||
);
|
||||
|
||||
create table reports_audit(
|
||||
report_id bigint NOT NULL,
|
||||
CREATE TABLE reports_audit(
|
||||
report_id BIGINT NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
handled_by_staff_id bigint,
|
||||
is_cleared bool NOT NULL,
|
||||
handled_by_staff_id BIGINT,
|
||||
is_cleared BOOL NOT NULL,
|
||||
FOREIGN KEY(handled_by_staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(report_id) REFERENCES reports(id)
|
||||
);
|
||||
|
||||
create table filename_ban(
|
||||
id bigserial PRIMARY KEY,
|
||||
board_id bigint,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE filename_ban(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
board_id BIGINT,
|
||||
staff_id BIGINT NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
filename VARCHAR(255) NOT NULL,
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table username_ban(
|
||||
id bigserial PRIMARY KEY,
|
||||
board_id bigint,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE username_ban(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
board_id BIGINT,
|
||||
staff_id BIGINT NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
username VARCHAR(255) NOT NULL,
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table file_ban(
|
||||
id bigserial PRIMARY KEY,
|
||||
board_id bigint,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE file_ban(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
board_id BIGINT,
|
||||
staff_id BIGINT NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
checksum int NOT NULL,
|
||||
checksum INT NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table wordfilters(
|
||||
id bigserial PRIMARY KEY,
|
||||
board_id bigint,
|
||||
staff_id bigint NOT NULL,
|
||||
CREATE TABLE wordfilters(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
board_id BIGINT,
|
||||
staff_id BIGINT NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
search VARCHAR(75) NOT NULL CHECK (search <> ''),
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
change_to VARCHAR(75) NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
-- Database version: 1
|
||||
|
||||
CREATE TABLE database_version(
|
||||
version int NOT NULL
|
||||
version INT NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO database_version(version)
|
||||
|
@ -20,11 +20,11 @@ CREATE TABLE sections(
|
|||
UNIQUE(position)
|
||||
);
|
||||
|
||||
create table boards(
|
||||
CREATE TABLE boards(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
section_id INTEGER NOT NULL,
|
||||
uri text NOT NULL,
|
||||
dir varchar(45) NOT NULL,
|
||||
uri TEXT NOT NULL,
|
||||
dir VARCHAR(45) NOT NULL,
|
||||
navbar_position SMALLINT NOT NULL,
|
||||
title VARCHAR(45) NOT NULL,
|
||||
subtitle VARCHAR(64) NOT NULL,
|
||||
|
@ -32,231 +32,231 @@ create table boards(
|
|||
max_file_size SMALLINT NOT NULL,
|
||||
max_threads SMALLINT NOT NULL,
|
||||
default_style VARCHAR(45) NOT NULL,
|
||||
locked bool NOT NULL,
|
||||
created_at timestamp NOT NULL,
|
||||
locked BOOL NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
anonymous_name VARCHAR(45) NOT NULL DEFAULT 'Anonymous',
|
||||
force_anonymous bool NOT NULL,
|
||||
force_anonymous BOOL NOT NULL,
|
||||
autosage_after SMALLINT NOT NULL,
|
||||
no_images_after SMALLINT NOT NULL,
|
||||
max_message_length SMALLINT NOT NULL,
|
||||
min_message_length SMALLINT NOT NULL,
|
||||
allow_embeds bool NOT NULL,
|
||||
redictect_to_thread bool NOT NULL,
|
||||
require_file bool NOT NULL,
|
||||
enable_catalog bool NOT NULL,
|
||||
allow_embeds BOOL NOT NULL,
|
||||
redictect_to_thread BOOL NOT NULL,
|
||||
require_file BOOL NOT NULL,
|
||||
enable_catalog BOOL NOT NULL,
|
||||
FOREIGN KEY(section_id) REFERENCES sections(id),
|
||||
UNIQUE(dir),
|
||||
UNIQUE(uri),
|
||||
UNIQUE(navbar_position)
|
||||
);
|
||||
|
||||
create table threads(
|
||||
CREATE TABLE threads(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
board_id INTEGER NOT NULL,
|
||||
locked bool NOT NULL,
|
||||
stickied bool NOT NULL,
|
||||
anchored bool NOT NULL,
|
||||
cyclical bool NOT NULL,
|
||||
last_bump timestamp NOT NULL,
|
||||
deleted_at timestamp NOT NULL,
|
||||
is_deleted bool NOT NULL,
|
||||
locked BOOL NOT NULL,
|
||||
stickied BOOL NOT NULL,
|
||||
anchored BOOL NOT NULL,
|
||||
cyclical BOOL NOT NULL,
|
||||
last_bump TIMESTAMP NOT NULL,
|
||||
deleted_at TIMESTAMP NOT NULL,
|
||||
is_deleted BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id)
|
||||
);
|
||||
|
||||
CREATE INDEX thread_deleted_index ON threads(is_deleted);
|
||||
|
||||
create table posts(
|
||||
CREATE TABLE posts(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
thread_id INTEGER NOT NULL,
|
||||
is_top_post bool NOT NULL,
|
||||
ip int NOT NULL,
|
||||
is_top_post BOOL NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
created_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
tripcode VARCHAR(10) NOT NULL,
|
||||
is_role_signature bool NOT NULL DEFAULT FALSE,
|
||||
is_role_signature BOOL NOT NULL DEFAULT FALSE,
|
||||
email VARCHAR(50) NOT NULL,
|
||||
subject VARCHAR(100) NOT NULL,
|
||||
message text NOT NULL,
|
||||
message_raw text NOT NULL,
|
||||
password text NOT NULL,
|
||||
deleted_at timestamp NOT NULL,
|
||||
is_deleted bool NOT NULL,
|
||||
banned_message text,
|
||||
message TEXT NOT NULL,
|
||||
message_raw TEXT NOT NULL,
|
||||
password TEXT NOT NULL,
|
||||
deleted_at TIMESTAMP NOT NULL,
|
||||
is_deleted BOOL NOT NULL,
|
||||
banned_message TEXT,
|
||||
FOREIGN KEY(thread_id) REFERENCES threads(id)
|
||||
);
|
||||
|
||||
CREATE INDEX top_post_index ON posts(is_top_post);
|
||||
|
||||
create table files(
|
||||
CREATE TABLE files(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
post_id INTEGER NOT NULL,
|
||||
file_order int NOT NULL,
|
||||
file_order INT NOT NULL,
|
||||
original_filename VARCHAR(255) NOT NULL,
|
||||
filename VARCHAR(45) NOT NULL,
|
||||
checksum int NOT NULL,
|
||||
file_size int NOT NULL,
|
||||
is_spoilered bool NOT NULL,
|
||||
checksum INT NOT NULL,
|
||||
file_size INT NOT NULL,
|
||||
is_spoilered BOOL NOT NULL,
|
||||
FOREIGN KEY(post_id) REFERENCES posts(id),
|
||||
UNIQUE(post_id, file_order)
|
||||
);
|
||||
|
||||
create table staff(
|
||||
CREATE TABLE staff(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
username VARCHAR(45) NOT NULL,
|
||||
password_checksum VARCHAR(120) NOT NULL,
|
||||
global_rank int,
|
||||
global_rank INT,
|
||||
added_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
last_login TIMESTAMP NOT NULL,
|
||||
is_active bool NOT NULL DEFAULT TRUE,
|
||||
is_active BOOL NOT NULL DEFAULT TRUE,
|
||||
UNIQUE(username)
|
||||
);
|
||||
|
||||
create table sessions(
|
||||
CREATE TABLE sessions(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
staff_id INTEGER NOT NULL,
|
||||
expires TIMESTAMP NOT NULL,
|
||||
data varchar(45) NOT NULL,
|
||||
data VARCHAR(45) NOT NULL,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table board_staff(
|
||||
CREATE TABLE board_staff(
|
||||
board_id INTEGER NOT NULL,
|
||||
staff_id INTEGER NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table announcements(
|
||||
CREATE TABLE announcements(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
staff_id INTEGER NOT NULL,
|
||||
subject VARCHAR(45) NOT NULL,
|
||||
message text NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table ip_ban(
|
||||
CREATE TABLE ip_ban(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
staff_id INTEGER NOT NULL,
|
||||
board_id INTEGER NOT NULL,
|
||||
banned_for_post_id INTEGER NOT NULL,
|
||||
copy_post_text text NOT NULL,
|
||||
is_active bool NOT NULL,
|
||||
ip int NOT NULL,
|
||||
copy_post_text TEXT NOT NULL,
|
||||
is_active BOOL NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL,
|
||||
appeal_at TIMESTAMP NOT NULL,
|
||||
expires_at TIMESTAMP NOT NULL,
|
||||
permanent bool NOT NULL,
|
||||
permanent BOOL NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
message text NOT NULL,
|
||||
can_appeal bool NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
can_appeal BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(banned_for_post_id) REFERENCES posts(id)
|
||||
);
|
||||
|
||||
create table ip_ban_audit(
|
||||
CREATE TABLE ip_ban_audit(
|
||||
ip_ban_id INTEGER NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
staff_id INTEGER NOT NULL,
|
||||
is_active bool NOT NULL,
|
||||
is_active BOOL NOT NULL,
|
||||
expires_at TIMESTAMP NOT NULL,
|
||||
appeal_at TIMESTAMP NOT NULL,
|
||||
permanent bool NOT NULL,
|
||||
permanent BOOL NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
message text NOT NULL,
|
||||
can_appeal bool NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
can_appeal BOOL NOT NULL,
|
||||
PRIMARY KEY(ip_ban_id, timestamp),
|
||||
FOREIGN KEY(ip_ban_id) REFERENCES ip_ban(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table ip_ban_appeals(
|
||||
CREATE TABLE ip_ban_appeals(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
staff_id INTEGER,
|
||||
ip_ban_id INTEGER NOT NULL,
|
||||
appeal_text text NOT NULL,
|
||||
staff_response text,
|
||||
is_denied bool NOT NULL,
|
||||
appeal_text TEXT NOT NULL,
|
||||
staff_response TEXT,
|
||||
is_denied BOOL NOT NULL,
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(ip_ban_id) REFERENCES ip_ban(id)
|
||||
);
|
||||
|
||||
create table ip_ban_appeals_audit(
|
||||
CREATE TABLE ip_ban_appeals_audit(
|
||||
appeal_id INTEGER NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
staff_id INTEGER,
|
||||
appeal_text text NOT NULL,
|
||||
staff_response text,
|
||||
is_denied bool NOT NULL,
|
||||
appeal_text TEXT NOT NULL,
|
||||
staff_response TEXT,
|
||||
is_denied BOOL NOT NULL,
|
||||
PRIMARY KEY(appeal_id, timestamp),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(appeal_id) REFERENCES ip_ban_appeals(id)
|
||||
);
|
||||
|
||||
create table reports(
|
||||
CREATE TABLE reports(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
handled_by_staff_id INTEGER,
|
||||
post_id INTEGER NOT NULL,
|
||||
ip int NOT NULL,
|
||||
reason text NOT NULL,
|
||||
is_cleared bool NOT NULL,
|
||||
ip INT NOT NULL,
|
||||
reason TEXT NOT NULL,
|
||||
is_cleared BOOL NOT NULL,
|
||||
FOREIGN KEY(handled_by_staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(post_id) REFERENCES posts(id)
|
||||
);
|
||||
|
||||
create table reports_audit(
|
||||
CREATE TABLE reports_audit(
|
||||
report_id INTEGER NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
handled_by_staff_id INTEGER,
|
||||
is_cleared bool NOT NULL,
|
||||
is_cleared BOOL NOT NULL,
|
||||
FOREIGN KEY(handled_by_staff_id) REFERENCES staff(id),
|
||||
FOREIGN KEY(report_id) REFERENCES reports(id)
|
||||
);
|
||||
|
||||
create table filename_ban(
|
||||
CREATE TABLE filename_ban(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
board_id INTEGER,
|
||||
staff_id INTEGER NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
filename VARCHAR(255) NOT NULL,
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table username_ban(
|
||||
CREATE TABLE username_ban(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
board_id INTEGER,
|
||||
staff_id INTEGER NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
username VARCHAR(255) NOT NULL,
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table file_ban(
|
||||
CREATE TABLE file_ban(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
board_id INTEGER,
|
||||
staff_id INTEGER NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
checksum int NOT NULL,
|
||||
checksum INT NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
);
|
||||
|
||||
create table wordfilters(
|
||||
CREATE TABLE wordfilters(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
board_id INTEGER,
|
||||
staff_id INTEGER NOT NULL,
|
||||
staff_note VARCHAR(255) NOT NULL,
|
||||
issued_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
search VARCHAR(75) NOT NULL CHECK (search <> ''),
|
||||
is_regex bool NOT NULL,
|
||||
is_regex BOOL NOT NULL,
|
||||
change_to VARCHAR(75) NOT NULL,
|
||||
FOREIGN KEY(board_id) REFERENCES boards(id),
|
||||
FOREIGN KEY(staff_id) REFERENCES staff(id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue