nekrochan/migrations/20230710121446_create_tables.up.sql

31 řádky
1.1 KiB
MySQL
Surový Normální zobrazení Historie

2023-12-11 15:18:43 +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
);
INSERT INTO accounts (username, password, owner, permissions) VALUES ('admin', '$2y$10$XcxAe19B1eWC15sfnDRyiuiNLZIhdL7PMTnTmtTfglJIz0zOpN3oa', true, '16383'::jsonb);