-- +goose Up -- +goose StatementBegin SELECT 'up SQL query'; create table if not exists chats ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, username TEXT DEFAULT '', topic INTEGER DEFAULT 0, active INTEGER DEFAULT 0, rules_msg TEXT DEFAULT '' ); create table if not exists activations ( id INTEGER PRIMARY KEY AUTOINCREMENT, code TEXT NOT NULL ); create table if not exists messagesToDelete ( id INTEGER PRIMARY KEY AUTOINCREMENT, message_id INTEGER NOT NULL, chat_id INTEGER NOT NULL, delete_date INTEGER NOT NULL, tries INTEGER DEFAULT 0 ); create table if not exists users ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, username TEXT DEFAULT '' ); create table if not exists admins ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, chat_id INTEGER NOT NULL, FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE, FOREIGN KEY (chat_id) REFERENCES chats (id) ON DELETE CASCADE ); create table if not exists bans ( id INTEGER PRIMARY KEY AUTOINCREMENT, chat_id INTEGER NOT NULL, user_id INTEGER NOT NULL, text TEXT DEFAULT '', reason TEXT DEFAULT '', ban_date INTEGER NOT NULL, unban_date INTEGER DEFAULT 0, FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE, FOREIGN KEY (chat_id) REFERENCES chats (id) ON DELETE CASCADE ); create table if not exists captchas ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER, chat_id INTEGER, message_id INTEGER, correct_answer TEXT DEFAULT '', blocked_until INTEGER DEFAULT 0, FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE, FOREIGN KEY (chat_id) REFERENCES chats (id) ON DELETE CASCADE ) -- +goose StatementEnd -- +goose Down -- +goose StatementBegin SELECT 'down SQL query'; drop table chats; drop table activations; drop table messagesToDelete; drop table users; drop table admins; drop table bans; drop table captchas; -- +goose StatementEnd