From 6c002985fddc923f57774c0ca5e7ddd36c629fdc Mon Sep 17 00:00:00 2001
From: ilotterytea <iltsu@alright.party>
Date: Wed, 2 Jul 2025 03:35:19 +0500
Subject: feat: new migrations

---
 migrations/2024-05-11T02-53-05_init/up.sql | 117 ++++++++++++++++-------------
 1 file changed, 64 insertions(+), 53 deletions(-)

(limited to 'migrations/2024-05-11T02-53-05_init/up.sql')

diff --git a/migrations/2024-05-11T02-53-05_init/up.sql b/migrations/2024-05-11T02-53-05_init/up.sql
index 2d4d8c2..afb26b7 100644
--- a/migrations/2024-05-11T02-53-05_init/up.sql
+++ b/migrations/2024-05-11T02-53-05_init/up.sql
@@ -1,72 +1,83 @@
 -- Your SQL goes here
-CREATE TABLE IF NOT EXISTS "channels"  (
-  "id" SERIAL NOT NULL UNIQUE PRIMARY KEY,
-  "alias_id" INTEGER NOT NULL UNIQUE,
-  "alias_name" VARCHAR NOT NULL UNIQUE,
-  "joined_at" TIMESTAMP NOT NULL DEFAULT timezone('utc', now()),
-  "opted_out_at" TIMESTAMP
+CREATE TABLE IF NOT EXISTS channels (
+  id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  alias_id INTEGER NOT NULL UNIQUE,
+  alias_name TEXT NOT NULL UNIQUE,
+  joined_at TIMESTAMP NOT NULL DEFAULT UTC_TIMESTAMP,
+  opted_out_at TIMESTAMP
 );
 
-CREATE TABLE IF NOT EXISTS "users"  (
-  "id" SERIAL NOT NULL UNIQUE PRIMARY KEY,
-  "alias_id" INTEGER NOT NULL UNIQUE,
-  "alias_name" VARCHAR NOT NULL UNIQUE,
-  "joined_at" TIMESTAMP NOT NULL DEFAULT timezone('utc', now()),
-  "opted_out_at" TIMESTAMP
+CREATE TABLE IF NOT EXISTS users (
+  id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  alias_id INTEGER NOT NULL UNIQUE,
+  alias_name TEXT NOT NULL UNIQUE,
+  joined_at TIMESTAMP NOT NULL DEFAULT UTC_TIMESTAMP,
+  opted_out_at TIMESTAMP
 );
 
-CREATE TABLE IF NOT EXISTS "channel_preferences" (
-  "channel_id" INTEGER NOT NULL UNIQUE PRIMARY KEY REFERENCES "channels"("id") ON DELETE CASCADE,
-  "prefix" VARCHAR,
-  "locale" VARCHAR
+CREATE TABLE IF NOT EXISTS channel_preferences (
+  id INTEGER NOT NULL PRIMARY KEY REFERENCES channels(id) ON DELETE CASCADE,
+  prefix TEXT,
+  locale TEXT,
+  silent_mode BOOLEAN NOT NULL DEFAULT FALSE,
+  markov_responses BOOLEAN NOT NULL DEFAULT FALSE,
+  random_markov_responses BOOLEAN NOT NULL DEFAULT FALSE
 );
 
-CREATE TABLE IF NOT EXISTS "user_rights" (
-  "id" SERIAL NOT NULL UNIQUE PRIMARY KEY,
-  "user_id" INTEGER NOT NULL REFERENCES "users"("id") ON DELETE CASCADE,
-  "channel_id" INTEGER NOT NULL REFERENCES "channels"("id") ON DELETE CASCADE,
-  "level" INTEGER NOT NULL DEFAULT 1,
+CREATE TABLE IF NOT EXISTS user_rights (
+  id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
+  channel_id INTEGER NOT NULL REFERENCES channels(id) ON DELETE CASCADE,
+  level INTEGER NOT NULL DEFAULT 1,
 
-  CONSTRAINT "unique_user_channel" UNIQUE ("user_id", "channel_id")
+  CONSTRAINT unique_user_channel UNIQUE (user_id, channel_id)
 );
 
-CREATE TABLE IF NOT EXISTS "actions" (
-  "id" SERIAL NOT NULL UNIQUE PRIMARY KEY,
-  "user_id" INTEGER NOT NULL REFERENCES "users"("id") ON DELETE CASCADE,
-  "channel_id" INTEGER NOT NULL REFERENCES "channels"("id") ON DELETE CASCADE,
-  "command" VARCHAR NOT NULL,
-  "arguments" VARCHAR,
-  "full_message" VARCHAR NOT NULL,
-  "sent_at" TIMESTAMP NOT NULL DEFAULT timezone('utc', now())
+CREATE TABLE IF NOT EXISTS actions (
+  id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
+  channel_id INTEGER NOT NULL REFERENCES channels(id) ON DELETE CASCADE,
+  command TEXT NOT NULL,
+  arguments TEXT,
+  full_message TEXT NOT NULL,
+  sent_at TIMESTAMP NOT NULL DEFAULT UTC_TIMESTAMP
 );
 
-CREATE TABLE IF NOT EXISTS "events" (
-  "id" SERIAL NOT NULL UNIQUE PRIMARY KEY,
-  "channel_id" INTEGER NOT NULL REFERENCES "channels"("id") ON DELETE CASCADE,
-  "name" VARCHAR NOT NULL,
-  "event_type" INTEGER NOT NULL,
-  "flags" INTEGER[] NOT NULL DEFAULT ARRAY[]::INTEGER[],
-  "message" VARCHAR NOT NULL
+CREATE TABLE IF NOT EXISTS events (
+  id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  channel_id INTEGER NOT NULL REFERENCES channels(id) ON DELETE CASCADE,
+  name TEXT NOT NULL,
+  event_type INTEGER NOT NULL,
+  is_massping BOOLEAN NOT NULL DEFAULT FALSE,
+  message TEXT NOT NULL
 );
 
-CREATE TABLE IF NOT EXISTS "event_subscriptions" (
-  "id" SERIAL NOT NULL UNIQUE PRIMARY KEY,
-  "event_id" INTEGER NOT NULL REFERENCES "events"("id") ON DELETE CASCADE,
-  "user_id" INTEGER NOT NULL REFERENCES "users"("id") ON DELETE CASCADE
+CREATE TABLE IF NOT EXISTS event_subscriptions (
+  id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  event_id INTEGER NOT NULL REFERENCES events(id) ON DELETE CASCADE,
+  user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE
 );
 
-CREATE TABLE IF NOT EXISTS "custom_commands" (
-  "id" SERIAL NOT NULL UNIQUE PRIMARY KEY,
-  "channel_id" INTEGER NOT NULL REFERENCES "channels"("id") ON DELETE CASCADE,
-  "name" VARCHAR NOT NULL,
-  "message" VARCHAR NOT NULL
+CREATE TABLE IF NOT EXISTS custom_commands (
+  id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  channel_id INTEGER NOT NULL REFERENCES channels(id) ON DELETE CASCADE,
+  name TEXT NOT NULL,
+  message TEXT NOT NULL
 );
 
-CREATE TABLE IF NOT EXISTS "timers" (
-  "id" SERIAL NOT NULL UNIQUE PRIMARY KEY,
-  "channel_id" INTEGER NOT NULL REFERENCES "channels"("id") ON DELETE CASCADE,
-  "name" VARCHAR NOT NULL,
-  "message" VARCHAR NOT NULL,
-  "interval_sec" INTEGER NOT NULL,
-  "last_executed_at" TIMESTAMP NOT NULL DEFAULT timezone('utc', now())
+CREATE TABLE IF NOT EXISTS custom_command_aliases (
+  id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  command_id INTEGER NOT NULL REFERENCES custom_commands(id) ON DELETE CASCADE,
+  name TEXT NOT NULL,
+
+  CONSTRAINT unique_command_alias UNIQUE (command_id, name)
+);
+
+CREATE TABLE IF NOT EXISTS timers (
+  id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  channel_id INTEGER NOT NULL REFERENCES channels(id) ON DELETE CASCADE,
+  name TEXT NOT NULL,
+  message TEXT NOT NULL,
+  interval_sec INTEGER NOT NULL,
+  last_executed_at TIMESTAMP NOT NULL DEFAULT UTC_TIMESTAMP
 );
-- 
cgit v1.2.3

