- calendar.php: raids and events live from the bot API (no duplicate data), recurring events projected forward, agenda list, mobile view with dots - Optionally public (without login, titles and times only), linked on the homepage - Members add their own entries (calendar_entries), participants via "I'm in", same protections as comments (filter, approval, report button, rate limit) - Moderation also covers calendar entries Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
526 lines
26 KiB
SQL
526 lines
26 KiB
SQL
-- Lumina Ascendens - Datenbankschema
|
|
-- Import dieser Datei z.B. über phpMyAdmin in eine leere Datenbank.
|
|
|
|
SET NAMES utf8mb4;
|
|
|
|
CREATE TABLE IF NOT EXISTS users (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
username VARCHAR(50) NOT NULL UNIQUE,
|
|
password_hash VARCHAR(255) NOT NULL,
|
|
display_name VARCHAR(100) NOT NULL DEFAULT '',
|
|
-- Aion-Klasse (AION_CLASSES) - von der Discord-Klassenrolle uebernommen oder im Profil gewaehlt
|
|
class_name VARCHAR(30) NULL,
|
|
-- Profilseite: frei geschriebener Text (Wiki-Format)
|
|
profile_bio TEXT NULL,
|
|
-- Kommentare unter den eigenen Galeriebildern (0 = abgeschaltet)
|
|
gallery_comments_enabled TINYINT(1) NOT NULL DEFAULT 1,
|
|
-- pending = per Discord angemeldet, aber noch nicht freigeschaltet.
|
|
status ENUM('active', 'disabled', 'pending') NOT NULL DEFAULT 'active',
|
|
must_change_password TINYINT(1) NOT NULL DEFAULT 0,
|
|
-- 0 = Anmeldung nur ueber Discord (Standard fuer per Discord angelegte Konten).
|
|
password_login TINYINT(1) NOT NULL DEFAULT 1,
|
|
-- 1 = Administrator: hat alle Berechtigungen, unabhaengig von den Gruppen
|
|
is_admin TINYINT(1) NOT NULL DEFAULT 0,
|
|
-- Hochzaehlen beendet alle Sitzungen des Kontos sofort
|
|
session_epoch INT UNSIGNED NOT NULL DEFAULT 0,
|
|
discord_id BIGINT UNSIGNED NULL UNIQUE,
|
|
discord_username VARCHAR(100) NULL,
|
|
-- OAuth-Token des Discord-Logins (Scopes identify + guilds.members.read), damit
|
|
-- Server-Mitgliedschaft und Rollen waehrend der Sitzung neu geprueft werden koennen.
|
|
discord_access_token VARCHAR(255) NULL,
|
|
discord_refresh_token VARCHAR(255) NULL,
|
|
discord_token_expires DATETIME NULL,
|
|
discord_synced_at DATETIME NULL,
|
|
-- Beitritt zum Discord-Server ("Dabei seit"), beim Discord-Abgleich gesetzt
|
|
discord_joined_at DATETIME NULL,
|
|
-- Einfuehrung im Dashboard abgeschlossen (NULL = Tour wird beim naechsten Besuch gezeigt)
|
|
tour_completed_at DATETIME NULL,
|
|
avatar_filename VARCHAR(255) NULL,
|
|
-- 1 = Profilbild wird von Discord uebernommen (0 nach eigenem Upload)
|
|
avatar_sync TINYINT(1) NOT NULL DEFAULT 1,
|
|
-- zuletzt uebernommenes Discord-Profilbild ("u:<hash>" global, "g:<hash>" Server-Profilbild, "" = keines)
|
|
discord_avatar VARCHAR(120) NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
last_login DATETIME NULL,
|
|
-- Zuletzt aktiv auf der Website (hoechstens alle paar Minuten aktualisiert)
|
|
last_seen_at DATETIME NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS roles (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
name VARCHAR(50) NOT NULL UNIQUE,
|
|
-- Wird ueberall dort angezeigt, wo Mitgliedern/Rollen im Frontend ein Name
|
|
-- gezeigt wird (Dashboard, Mitgliederliste, ...) - "name" oben bleibt dabei
|
|
-- der interne, eindeutige Identifizierer. Leer = "name" wird als Anzeige
|
|
-- verwendet (Fallback).
|
|
display_name VARCHAR(100) NOT NULL DEFAULT '',
|
|
description VARCHAR(255) NOT NULL DEFAULT '',
|
|
is_system TINYINT(1) NOT NULL DEFAULT 0,
|
|
-- NULL = Mitglieder dieser Rolle erscheinen in der Mitgliederliste nur in der
|
|
-- allgemeinen Gruppe. Eine Zahl gibt der Rolle dort eine eigene Gruppe und
|
|
-- bestimmt deren Reihenfolge (aufsteigend, z.B. 1 = zuerst).
|
|
roster_order INT NULL DEFAULT NULL,
|
|
-- Verknuepfte Discord-Rolle: wer sie auf dem Server hat, ist automatisch in dieser
|
|
-- Gruppe, wer sie verliert, fliegt raus. NULL = Gruppe wird von Hand vergeben.
|
|
discord_role_id BIGINT UNSIGNED NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS permissions (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
`key` VARCHAR(100) NOT NULL UNIQUE,
|
|
description VARCHAR(255) NOT NULL DEFAULT ''
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS role_permissions (
|
|
role_id INT UNSIGNED NOT NULL,
|
|
permission_id INT UNSIGNED NOT NULL,
|
|
PRIMARY KEY (role_id, permission_id),
|
|
FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (permission_id) REFERENCES permissions(id) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- Einstellungen der Website, die die Leitung in der Oberflaeche aendert (z.B. ob Mitglieder
|
|
-- ihre Discord-Verknuepfung loesen duerfen). Fehlende Eintraege = Standardwert im Code.
|
|
CREATE TABLE IF NOT EXISTS settings (
|
|
`key` VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
value TEXT NOT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- Fehlermeldungen der Mitglieder (Dashboard), bearbeitet unter /bugs.php
|
|
CREATE TABLE IF NOT EXISTS bug_reports (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
user_id INT UNSIGNED NULL,
|
|
title VARCHAR(150) NOT NULL,
|
|
area VARCHAR(30) NOT NULL,
|
|
description TEXT NOT NULL,
|
|
screenshot_url VARCHAR(500) NULL,
|
|
user_agent VARCHAR(255) NULL,
|
|
status ENUM('open', 'in_progress', 'done', 'rejected') NOT NULL DEFAULT 'open',
|
|
admin_note TEXT NULL,
|
|
handled_by INT UNSIGNED NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NULL,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL,
|
|
FOREIGN KEY (handled_by) REFERENCES users(id) ON DELETE SET NULL,
|
|
INDEX idx_bug_reports_status (status),
|
|
INDEX idx_bug_reports_user (user_id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS user_roles (
|
|
user_id INT UNSIGNED NOT NULL,
|
|
role_id INT UNSIGNED NOT NULL,
|
|
PRIMARY KEY (user_id, role_id),
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- --------------------------------------------------------------------------
|
|
-- Raids: Einstellungen und Anwesenheit (die Raids selbst liegen beim Bot)
|
|
-- --------------------------------------------------------------------------
|
|
|
|
CREATE TABLE IF NOT EXISTS raid_settings (
|
|
-- Discord-Nachrichten-ID des Raids (wie in der Raid-API), 19-stellig
|
|
raid_id BIGINT UNSIGNED NOT NULL PRIMARY KEY,
|
|
-- Automatische Lumipunkte beim Archivieren: fuer Anwesende bzw. Abzug fuer Abwesende
|
|
points_present INT NOT NULL DEFAULT 0,
|
|
points_absent INT NOT NULL DEFAULT 0,
|
|
-- Wann die Automatik gelaufen ist (oder uebersprungen wurde, weil schon Punkte vergeben waren)
|
|
auto_processed_at DATETIME NULL,
|
|
auto_result VARCHAR(255) NULL,
|
|
-- Anwesenheitsliste als kontrolliert bestaetigt
|
|
attendance_checked_at DATETIME NULL,
|
|
attendance_checked_by INT UNSIGNED NULL,
|
|
FOREIGN KEY (attendance_checked_by) REFERENCES users(id) ON DELETE SET NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS raid_attendance (
|
|
raid_id BIGINT UNSIGNED NOT NULL,
|
|
-- Discord-ID wie in den Raid-Anmeldungen; zugeordnet zu Website-Konten ueber users.discord_id
|
|
discord_id BIGINT UNSIGNED NOT NULL,
|
|
name VARCHAR(100) NOT NULL DEFAULT '',
|
|
status ENUM('present', 'absent', 'excused') NOT NULL,
|
|
updated_by INT UNSIGNED NULL,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (raid_id, discord_id),
|
|
FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- --------------------------------------------------------------------------
|
|
-- Lumipunkte
|
|
-- --------------------------------------------------------------------------
|
|
|
|
-- Eine Vergabe: Anlass (Raid, Event, ...) mit Grund und Datum.
|
|
CREATE TABLE IF NOT EXISTS contribution_awards (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
-- raid, event, other (CONTRIBUTION_CATEGORIES in includes/contributions.php)
|
|
category VARCHAR(20) NOT NULL,
|
|
title VARCHAR(150) NOT NULL,
|
|
note VARCHAR(255) NULL,
|
|
-- Raid aus der Raid-API, wenn die Punkte fuer einen Raid vergeben wurden
|
|
raid_id BIGINT UNSIGNED NULL,
|
|
awarded_at DATETIME NOT NULL,
|
|
created_by INT UNSIGNED NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
|
INDEX idx_contribution_awards_time (awarded_at)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- Die beteiligten Mitglieder einer Vergabe mit ihren Punkten. Der Punktestand ist die Summe.
|
|
CREATE TABLE IF NOT EXISTS contribution_entries (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
award_id INT UNSIGNED NOT NULL,
|
|
user_id INT UNSIGNED NOT NULL,
|
|
-- Negativ = Abzug
|
|
points INT NOT NULL,
|
|
UNIQUE KEY uq_contribution_entry (award_id, user_id),
|
|
FOREIGN KEY (award_id) REFERENCES contribution_awards(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
INDEX idx_contribution_entries_user (user_id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- --------------------------------------------------------------------------
|
|
-- Lagerhaus
|
|
-- --------------------------------------------------------------------------
|
|
|
|
-- Gegenstandsliste: die Eintraege aus dem Aion-2-Wiki uebernimmt die Website beim ersten
|
|
-- Aufruf des Lagerhauses selbst aus includes/data/warehouse_items.json.
|
|
CREATE TABLE IF NOT EXISTS warehouse_items (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
name VARCHAR(150) NOT NULL,
|
|
-- Schluessel aus WAREHOUSE_CATEGORIES in includes/warehouse.php (sword, boots, ...)
|
|
category VARCHAR(30) NOT NULL,
|
|
-- Dateiname des Bildes unter assets/images/warehouse/ (NULL = Platzhalter)
|
|
icon VARCHAR(120) NULL,
|
|
-- wiki = aus includes/data/warehouse_items.json, custom = in der Oberflaeche angelegt
|
|
source ENUM('wiki', 'custom') NOT NULL DEFAULT 'wiki',
|
|
created_by INT UNSIGNED NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
UNIQUE KEY uq_warehouse_items_name (name),
|
|
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- Jede Einlagerung und Entnahme. Der Bestand ergibt sich aus der Summe.
|
|
CREATE TABLE IF NOT EXISTS warehouse_movements (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
item_id INT UNSIGNED NOT NULL,
|
|
-- in = eingelagert, out = entnommen
|
|
direction ENUM('in', 'out') NOT NULL,
|
|
-- BIGINT wegen Kina (Betraege weit ueber 4 Milliarden moeglich)
|
|
quantity BIGINT UNSIGNED NOT NULL,
|
|
-- Wann uebergeben/entnommen (wie eingegeben, deutsche Zeit)
|
|
occurred_at DATETIME NOT NULL,
|
|
-- Von wem (in) bzw. an wen (out): ein Konto der Website oder ein frei eingetragener Name
|
|
counterpart_user_id INT UNSIGNED NULL,
|
|
counterpart_name VARCHAR(100) NULL,
|
|
note VARCHAR(255) NULL,
|
|
created_by INT UNSIGNED NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (item_id) REFERENCES warehouse_items(id) ON DELETE RESTRICT,
|
|
FOREIGN KEY (counterpart_user_id) REFERENCES users(id) ON DELETE SET NULL,
|
|
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
|
INDEX idx_warehouse_movements_item (item_id),
|
|
INDEX idx_warehouse_movements_time (occurred_at)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- --------------------------------------------------------------------------
|
|
-- Lumishop
|
|
-- --------------------------------------------------------------------------
|
|
|
|
CREATE TABLE IF NOT EXISTS shop_categories (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
name VARCHAR(80) NOT NULL,
|
|
sort_order INT NOT NULL DEFAULT 0,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS shop_items (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
category_id INT UNSIGNED NULL,
|
|
name VARCHAR(150) NOT NULL,
|
|
description VARCHAR(500) NULL,
|
|
-- Preis in Lumipunkten pro Stueck
|
|
price INT UNSIGNED NOT NULL,
|
|
-- manual = eigener Bestand (stock), warehouse = Bestand des Lagerhaus-Gegenstands, unlimited
|
|
stock_mode ENUM('manual', 'warehouse', 'unlimited') NOT NULL DEFAULT 'manual',
|
|
stock INT UNSIGNED NOT NULL DEFAULT 0,
|
|
-- Verknuepfter Lagerhaus-Gegenstand: liefert das Bild und bei stock_mode = warehouse den Bestand
|
|
warehouse_item_id INT UNSIGNED NULL,
|
|
active TINYINT(1) NOT NULL DEFAULT 1,
|
|
created_by INT UNSIGNED NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NULL,
|
|
FOREIGN KEY (category_id) REFERENCES shop_categories(id) ON DELETE SET NULL,
|
|
FOREIGN KEY (warehouse_item_id) REFERENCES warehouse_items(id) ON DELETE SET NULL,
|
|
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS shop_orders (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
user_id INT UNSIGNED NOT NULL,
|
|
item_id INT UNSIGNED NULL,
|
|
-- Name und Preis zum Zeitpunkt der Bestellung (bleiben, auch wenn der Gegenstand spaeter
|
|
-- geaendert oder geloescht wird)
|
|
item_name VARCHAR(150) NOT NULL,
|
|
-- Anzahl (nach einer Teilbewilligung die bewilligte) und die urspruenglich beantragte
|
|
quantity INT UNSIGNED NOT NULL,
|
|
requested_quantity INT UNSIGNED NOT NULL,
|
|
unit_price INT UNSIGNED NOT NULL,
|
|
total_price INT UNSIGNED NOT NULL,
|
|
-- Bemerkung des Mitglieds (z.B. Charaktername)
|
|
note VARCHAR(255) NULL,
|
|
-- pending, approved, delivered, rejected, cancelled (SHOP_STATUSES in includes/shop.php)
|
|
status ENUM('pending', 'approved', 'delivered', 'rejected', 'cancelled') NOT NULL DEFAULT 'pending',
|
|
decision_note VARCHAR(255) NULL,
|
|
decided_by INT UNSIGNED NULL,
|
|
decided_at DATETIME NULL,
|
|
delivered_by INT UNSIGNED NULL,
|
|
delivered_at DATETIME NULL,
|
|
-- Die Vergabe mit dem Punkteabzug und die Entnahme im Lagerhaus (fuer eine Stornierung)
|
|
award_id INT UNSIGNED NULL,
|
|
warehouse_movement_id INT UNSIGNED NULL,
|
|
-- 1 = bei der Bewilligung wurde der eigene Bestand im Shop verringert
|
|
stock_taken TINYINT(1) NOT NULL DEFAULT 0,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (item_id) REFERENCES shop_items(id) ON DELETE SET NULL,
|
|
FOREIGN KEY (decided_by) REFERENCES users(id) ON DELETE SET NULL,
|
|
FOREIGN KEY (delivered_by) REFERENCES users(id) ON DELETE SET NULL,
|
|
FOREIGN KEY (award_id) REFERENCES contribution_awards(id) ON DELETE SET NULL,
|
|
FOREIGN KEY (warehouse_movement_id) REFERENCES warehouse_movements(id) ON DELETE SET NULL,
|
|
INDEX idx_shop_orders_status (status),
|
|
INDEX idx_shop_orders_user (user_id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- --------------------------------------------------------------------------
|
|
-- Taktiken auf der Karte
|
|
-- --------------------------------------------------------------------------
|
|
|
|
-- Eine Taktik gehoert zu einer Region der Karte (map_slug aus assets/map/data/maps.json)
|
|
-- und besteht aus nacheinander ablaufenden Schritten.
|
|
CREATE TABLE IF NOT EXISTS tactics (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
map_slug VARCHAR(60) NOT NULL,
|
|
name VARCHAR(120) NOT NULL,
|
|
description TEXT NULL,
|
|
created_by INT UNSIGNED NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NULL,
|
|
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
|
INDEX idx_tactics_map (map_slug)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- Ein Schritt ist eine eigene Zeichenebene ("Schritt 1: Sammeln", "Schritt 2: Angriff").
|
|
CREATE TABLE IF NOT EXISTS tactic_steps (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
tactic_id INT UNSIGNED NOT NULL,
|
|
title VARCHAR(120) NOT NULL DEFAULT '',
|
|
description TEXT NULL,
|
|
sort_order INT NOT NULL DEFAULT 0,
|
|
FOREIGN KEY (tactic_id) REFERENCES tactics(id) ON DELETE CASCADE,
|
|
INDEX idx_tactic_steps_tactic (tactic_id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- points enthaelt die Stuetzpunkte als JSON-Array [[x,y], ...] in Weltkoordinaten der
|
|
-- Karte (0..4096, dieselben wie die Marker). TEXT statt JSON, damit auch aeltere
|
|
-- MySQL-/MariaDB-Versionen ohne JSON-Typ funktionieren.
|
|
CREATE TABLE IF NOT EXISTS tactic_shapes (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
step_id INT UNSIGNED NOT NULL,
|
|
shape_type ENUM('pen', 'line', 'arrow', 'area', 'circle', 'point', 'text') NOT NULL,
|
|
label VARCHAR(200) NOT NULL DEFAULT '',
|
|
color VARCHAR(7) NOT NULL DEFAULT '#ffd700',
|
|
width TINYINT UNSIGNED NOT NULL DEFAULT 4,
|
|
points MEDIUMTEXT NOT NULL,
|
|
created_by INT UNSIGNED NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (step_id) REFERENCES tactic_steps(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
|
INDEX idx_tactic_shapes_step (step_id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- Wiki (Einsteiger-Guide): Kapitel und Unterseiten, Versionen, Mitwirkende
|
|
CREATE TABLE IF NOT EXISTS wiki_pages (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
parent_id INT UNSIGNED NULL,
|
|
title VARCHAR(150) NOT NULL,
|
|
slug VARCHAR(170) NOT NULL UNIQUE,
|
|
content MEDIUMTEXT NOT NULL,
|
|
is_wip TINYINT(1) NOT NULL DEFAULT 0,
|
|
sort_order INT NOT NULL DEFAULT 0,
|
|
created_by INT UNSIGNED NULL,
|
|
updated_by INT UNSIGNED NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (parent_id) REFERENCES wiki_pages(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
|
FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL,
|
|
INDEX idx_wiki_pages_parent (parent_id, sort_order)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS wiki_revisions (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
page_id INT UNSIGNED NOT NULL,
|
|
title VARCHAR(150) NOT NULL,
|
|
content MEDIUMTEXT NOT NULL,
|
|
is_wip TINYINT(1) NOT NULL DEFAULT 0,
|
|
summary VARCHAR(255) NULL,
|
|
edited_by INT UNSIGNED NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (page_id) REFERENCES wiki_pages(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (edited_by) REFERENCES users(id) ON DELETE SET NULL,
|
|
INDEX idx_wiki_revisions_page (page_id, created_at)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS wiki_contributors (
|
|
user_id INT UNSIGNED NOT NULL PRIMARY KEY,
|
|
added_by INT UNSIGNED NULL,
|
|
added_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (added_by) REFERENCES users(id) ON DELETE SET NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- Profilseiten: Charaktere und Bildergalerie der Mitglieder (Bilder unter assets/uploads/profiles/)
|
|
CREATE TABLE IF NOT EXISTS member_characters (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
user_id INT UNSIGNED NOT NULL,
|
|
name VARCHAR(60) NOT NULL,
|
|
class_name VARCHAR(30) NULL,
|
|
level SMALLINT UNSIGNED NULL,
|
|
note VARCHAR(255) NULL,
|
|
portrait_filename VARCHAR(120) NULL,
|
|
image_filename VARCHAR(120) NULL,
|
|
is_main TINYINT(1) NOT NULL DEFAULT 0,
|
|
sort_order INT NOT NULL DEFAULT 0,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
INDEX idx_member_characters_user (user_id, sort_order)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS member_gallery (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
user_id INT UNSIGNED NOT NULL,
|
|
filename VARCHAR(120) NOT NULL,
|
|
caption VARCHAR(150) NULL,
|
|
-- visible = fuer alle sichtbar, pending = wartet auf Freigabe (Vertrauensstufe, Link, KI-Pruefung, Meldungen)
|
|
status VARCHAR(10) NOT NULL DEFAULT 'visible',
|
|
moderation_note VARCHAR(255) NULL,
|
|
sort_order INT NOT NULL DEFAULT 0,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
INDEX idx_member_gallery_user (user_id, sort_order)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- Audit-Log, Tempolimits (Spam-Schutz) und Kommentare unter Galeriebildern
|
|
CREATE TABLE IF NOT EXISTS audit_log (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
-- Wer (NULL = unbekannt/abgemeldet, z.B. fehlgeschlagener Login); Name bleibt auch nach dem Loeschen des Kontos
|
|
user_id INT UNSIGNED NULL,
|
|
actor_name VARCHAR(100) NOT NULL DEFAULT '',
|
|
-- Bereich (siehe AUDIT_AREAS in includes/security.php), Titel und Details (JSON: Name => Wert)
|
|
area VARCHAR(30) NOT NULL,
|
|
title VARCHAR(256) NOT NULL,
|
|
details TEXT NULL,
|
|
tone VARCHAR(10) NOT NULL DEFAULT 'info',
|
|
-- gekuerzte IP (letzter Block genullt) - reicht zum Wiedererkennen, ohne sie ganz zu speichern
|
|
ip VARCHAR(45) NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL,
|
|
INDEX idx_audit_log_time (created_at),
|
|
INDEX idx_audit_log_user (user_id, created_at),
|
|
INDEX idx_audit_log_area (area, created_at)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS rate_limits (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
-- Art der Aktion (z.B. post, upload, login) und wer (Konto-ID, IP oder Benutzername)
|
|
bucket VARCHAR(40) NOT NULL,
|
|
subject VARCHAR(120) NOT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
INDEX idx_rate_limits_lookup (bucket, subject, created_at),
|
|
INDEX idx_rate_limits_time (created_at)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS gallery_comments (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
-- Kommentar unter einem Bild der Profil-Galerie
|
|
gallery_id INT UNSIGNED NOT NULL,
|
|
author_id INT UNSIGNED NULL,
|
|
body TEXT NOT NULL,
|
|
-- visible = fuer alle sichtbar, pending = wartet auf Freigabe (Vertrauensstufe, Link, KI-Pruefung, Meldungen)
|
|
status VARCHAR(10) NOT NULL DEFAULT 'visible',
|
|
moderation_note VARCHAR(255) NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (gallery_id) REFERENCES member_gallery(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
INDEX idx_gallery_comments_picture (gallery_id, created_at),
|
|
INDEX idx_gallery_comments_author (author_id, created_at)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS content_reports (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
-- Gemeldeter Inhalt: picture = member_gallery.id, comment = gallery_comments.id
|
|
content_type VARCHAR(20) NOT NULL,
|
|
content_id INT UNSIGNED NOT NULL,
|
|
reporter_id INT UNSIGNED NOT NULL,
|
|
reason VARCHAR(255) NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (reporter_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
UNIQUE KEY uq_content_reports (content_type, content_id, reporter_id),
|
|
INDEX idx_content_reports_content (content_type, content_id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- Schimpfwortfilter der Moderation (Startliste legt includes/moderation.php an)
|
|
CREATE TABLE IF NOT EXISTS moderation_words (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
-- Wort (klein geschrieben); * am Anfang/Ende = auch als Wortteil (z.B. fick*)
|
|
word VARCHAR(60) NOT NULL,
|
|
-- flag = nur markieren, hold = erst nach Freigabe sichtbar, block = wird nicht gespeichert
|
|
action VARCHAR(10) NOT NULL DEFAULT 'flag',
|
|
created_by INT UNSIGNED NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
UNIQUE KEY uq_moderation_words (word),
|
|
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- Reaktionen (Emojis) unter Galeriebildern und Kommentaren
|
|
CREATE TABLE IF NOT EXISTS reactions (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
-- Reaktion auf: picture = member_gallery.id, comment = gallery_comments.id
|
|
content_type VARCHAR(20) NOT NULL,
|
|
content_id INT UNSIGNED NOT NULL,
|
|
user_id INT UNSIGNED NOT NULL,
|
|
-- ein Emoji aus REACTION_EMOJIS (includes/reactions.php)
|
|
emoji VARCHAR(16) NOT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
UNIQUE KEY uq_reactions (content_type, content_id, user_id, emoji),
|
|
INDEX idx_reactions_content (content_type, content_id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
-- Termine, die Mitglieder selbst in den Kalender eintragen, und wer dabei ist
|
|
CREATE TABLE IF NOT EXISTS calendar_entries (
|
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
-- Von Mitgliedern eingetragene Termine (Raids und Events kommen aus der Bot-API)
|
|
user_id INT UNSIGNED NOT NULL,
|
|
title VARCHAR(100) NOT NULL,
|
|
description TEXT NULL,
|
|
starts_at DATETIME NOT NULL,
|
|
ends_at DATETIME NULL,
|
|
-- visible / pending (Moderation wie bei Kommentaren)
|
|
status VARCHAR(10) NOT NULL DEFAULT 'visible',
|
|
moderation_note VARCHAR(255) NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NULL,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
INDEX idx_calendar_entries_start (starts_at)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS calendar_participants (
|
|
entry_id INT UNSIGNED NOT NULL,
|
|
user_id INT UNSIGNED NOT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (entry_id, user_id),
|
|
FOREIGN KEY (entry_id) REFERENCES calendar_entries(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|