-- CreateTable
CREATE TABLE "appeals" (
    "approved" BOOLEAN,
    "ban_reason" TEXT NOT NULL,
    "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "id" TEXT NOT NULL PRIMARY KEY,
    "learned" TEXT NOT NULL,
    "reason_for_unban" TEXT NOT NULL,
    "user" JSONB NOT NULL
);

-- CreateTable
CREATE TABLE "appeal_bans" (
    "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "created_by" TEXT NOT NULL,
    "user" TEXT NOT NULL PRIMARY KEY
);

-- CreateTable
CREATE TABLE "et_members" (
    "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "created_by" TEXT NOT NULL,
    "id" TEXT NOT NULL PRIMARY KEY,
    "is_management" BOOLEAN NOT NULL DEFAULT false,
    "name" TEXT NOT NULL,
    "points" INTEGER NOT NULL DEFAULT 0,
    "roblox_id" INTEGER
);

-- CreateTable
CREATE TABLE "et_strikes" (
    "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "created_by" TEXT NOT NULL,
    "id" TEXT NOT NULL PRIMARY KEY,
    "reason" TEXT NOT NULL,
    "user" TEXT NOT NULL
);

-- CreateTable
CREATE TABLE "events" (
    "answer" TEXT,
    "answered_at" DATETIME,
    "approved" BOOLEAN NOT NULL DEFAULT false,
    "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "created_by" TEXT NOT NULL,
    "day" INTEGER NOT NULL,
    "details" TEXT NOT NULL,
    "id" TEXT NOT NULL PRIMARY KEY,
    "month" INTEGER NOT NULL,
    "pending" BOOLEAN NOT NULL DEFAULT true,
    "performed_at" DATETIME,
    "reached_minimum_player_count" BOOLEAN NOT NULL DEFAULT false,
    "type" TEXT NOT NULL,
    "year" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "game_appeals" (
    "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "id" TEXT NOT NULL PRIMARY KEY,
    "reason_for_unban" TEXT NOT NULL,
    "roblox_id" INTEGER NOT NULL,
    "roblox_username" TEXT NOT NULL,
    "type" TEXT NOT NULL,
    "what_happened" TEXT NOT NULL
);

-- CreateTable
CREATE TABLE "game_mod_logs" (
    "action" TEXT NOT NULL,
    "evidence" TEXT NOT NULL,
    "executed_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "executor" TEXT NOT NULL,
    "id" TEXT NOT NULL PRIMARY KEY,
    "target" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "game_mod_notes" (
    "content" TEXT NOT NULL,
    "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "created_by" TEXT NOT NULL,
    "id" TEXT NOT NULL PRIMARY KEY,
    "target" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "inactivity_notices" (
    "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "decisions" JSONB NOT NULL,
    "departments" JSONB NOT NULL DEFAULT [],
    "end" TEXT NOT NULL,
    "hiatus" BOOLEAN NOT NULL DEFAULT false,
    "id" TEXT NOT NULL PRIMARY KEY,
    "reason" TEXT NOT NULL,
    "start" TEXT NOT NULL,
    "user" JSONB NOT NULL
);

-- CreateTable
CREATE TABLE "push_notifications" (
    "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "event_id" TEXT NOT NULL,
    "event_type" TEXT NOT NULL,
    "token" TEXT NOT NULL
);

-- CreateTable
CREATE TABLE "reports" (
    "attachments" JSONB NOT NULL DEFAULT [],
    "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "id" TEXT NOT NULL PRIMARY KEY,
    "open" BOOLEAN NOT NULL DEFAULT true,
    "target_ids" JSONB NOT NULL DEFAULT [],
    "target_usernames" JSONB NOT NULL DEFAULT [],
    "type" TEXT NOT NULL DEFAULT 'exploit',
    "user" JSONB
);

-- CreateTable
CREATE TABLE "short_links" (
    "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "destination" TEXT NOT NULL,
    "path" TEXT NOT NULL PRIMARY KEY,
    "user" TEXT NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "appeals_id_key" ON "appeals"("id");

-- CreateIndex
CREATE INDEX "idx_appeals_approved_created_at" ON "appeals"("approved", "created_at");

-- CreateIndex
CREATE UNIQUE INDEX "appeal_bans_user_key" ON "appeal_bans"("user");

-- CreateIndex
CREATE UNIQUE INDEX "et_members_id_key" ON "et_members"("id");

-- CreateIndex
CREATE INDEX "idx_et_members_id_name" ON "et_members"("id", "name");

-- CreateIndex
CREATE UNIQUE INDEX "et_strikes_id_key" ON "et_strikes"("id");

-- CreateIndex
CREATE UNIQUE INDEX "events_id_key" ON "events"("id");

-- CreateIndex
CREATE INDEX "idx_events_month_year" ON "events"("month", "year");

-- CreateIndex
CREATE UNIQUE INDEX "game_appeals_id_key" ON "game_appeals"("id");

-- CreateIndex
CREATE INDEX "idx_game_appeals_created_at" ON "game_appeals"("created_at");

-- CreateIndex
CREATE UNIQUE INDEX "game_mod_logs_id_key" ON "game_mod_logs"("id");

-- CreateIndex
CREATE INDEX "idx_game_mod_logs_target" ON "game_mod_logs"("target");

-- CreateIndex
CREATE UNIQUE INDEX "game_mod_notes_id_key" ON "game_mod_notes"("id");

-- CreateIndex
CREATE INDEX "idx_game_mod_notes_target" ON "game_mod_notes"("target");

-- CreateIndex
CREATE UNIQUE INDEX "inactivity_notices_id_key" ON "inactivity_notices"("id");

-- CreateIndex
CREATE INDEX "idx_inactivity_notices_end_start" ON "inactivity_notices"("end", "start");

-- CreateIndex
CREATE UNIQUE INDEX "push_notifications_event_id_key" ON "push_notifications"("event_id");

-- CreateIndex
CREATE UNIQUE INDEX "reports_id_key" ON "reports"("id");

-- CreateIndex
CREATE INDEX "idx_reports_created_at_open" ON "reports"("created_at", "open");

-- CreateIndex
CREATE UNIQUE INDEX "short_links_path_key" ON "short_links"("path");
