nekrochan/migrations/20230710121446_create_tables.sql

29 řádky
923 B
MySQL
Surový Normální zobrazení Historie

2024-03-16 11:20:50 +00:00
CREATE TABLE accounts (
username VARCHAR(32) NOT NULL PRIMARY KEY,
password VARCHAR(64) NOT NULL,
owner BOOLEAN NOT NULL DEFAULT false,
permissions JSONB NOT NULL DEFAULT '0'::jsonb,
created TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE boards (
id VARCHAR(16) NOT NULL PRIMARY KEY,
name VARCHAR(32) NOT NULL,
description VARCHAR(128) NOT NULL,
banners JSONB NOT NULL,
config JSONB NOT NULL,
created TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE bans (
id SERIAL NOT NULL PRIMARY KEY,
ip_range INET NOT NULL,
reason TEXT NOT NULL,
board VARCHAR(16) DEFAULT NULL REFERENCES boards(id),
issued_by VARCHAR(32) NOT NULL REFERENCES accounts(username),
appealable BOOLEAN NOT NULL DEFAULT true,
appeal TEXT DEFAULT NULL,
expires TIMESTAMPTZ DEFAULT NULL,
created TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);