LuminaWebsite/sql/schema.sql
Maaxxs 6b5661dd53 Karte: tactical map tab with own markers and tactic layers
New "Karte" tab: a tiled zoom/pan map of the game world with a category
sidebar (groups, per-category marker counts, show all / hide all, search)
and marker popups, plus tactic layers drawn on top of it.

Markers are placed by clicking the map (map.manage) and live in freely
editable two-level categories, each with its own emoji and colour. A tactic
(map.tactics) is a separate drawing layer that can be toggled on and off:
rally points, dashed routes, areas and text notes in any colour, finished by
double click, an explicit button or Enter, removed by clicking them.

Coordinates are stored as a fraction of the map's width/height rather than
in pixels, so re-tiling the map at a different resolution never moves
anything.

The map data lives entirely in the website database - the Discord bot is not
involved. tools/make_map_tiles.php slices a high-resolution image into the
zoom pyramid locally; the resulting folder is uploaded by FTP and picked up
automatically, one region per folder. Leaflet 1.9.4 is vendored under
assets/vendor/ so there is still no CDN and no build step.

New permissions map.view / map.manage / map.tactics and four new tables -
existing installs have to add both once (see README).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 13:25:12 +02:00

123 lines
5.7 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 '',
status ENUM('active', 'disabled') NOT NULL DEFAULT 'active',
must_change_password TINYINT(1) NOT NULL DEFAULT 0,
discord_id BIGINT UNSIGNED NULL UNIQUE,
discord_username VARCHAR(100) NULL,
avatar_filename VARCHAR(255) NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_login 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,
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;
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;
-- --------------------------------------------------------------------------
-- Taktikkarte
-- --------------------------------------------------------------------------
-- Kategorien sind zweistufig: Zeilen ohne parent_id sind Gruppen ("Ressourcen"),
-- Zeilen mit parent_id die eigentlichen Marker-Kategorien ("Orihalum-Erz").
CREATE TABLE IF NOT EXISTS map_categories (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
parent_id INT UNSIGNED NULL,
name VARCHAR(80) NOT NULL,
-- Kurzes Zeichen (Emoji) fuer die Marker-Nadel, z.B. "⛏" oder "🐉".
icon VARCHAR(16) NOT NULL DEFAULT '',
color VARCHAR(7) NOT NULL DEFAULT '#c9a227',
sort_order INT NOT NULL DEFAULT 0,
FOREIGN KEY (parent_id) REFERENCES map_categories(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- pos_x/pos_y sind auf 0..1 normiert (Anteil der Kartenbreite/-hoehe), damit die
-- Marker unabhaengig von Zoomstufe, Kachelgroesse und Bildaufloesung sitzen und ein
-- spaeter neu gekacheltes Kartenbild sie nicht verschiebt.
CREATE TABLE IF NOT EXISTS map_markers (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
map_key VARCHAR(50) NOT NULL DEFAULT 'verteron',
category_id INT UNSIGNED NOT NULL,
name VARCHAR(120) NOT NULL,
description TEXT NULL,
pos_x DECIMAL(9,6) NOT NULL,
pos_y DECIMAL(9,6) NOT NULL,
created_by INT UNSIGNED NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NULL,
FOREIGN KEY (category_id) REFERENCES map_categories(id) ON DELETE CASCADE,
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
INDEX idx_map_markers_map (map_key),
INDEX idx_map_markers_category (category_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Eine Taktik ist eine eigene Zeichenebene ueber der Karte (Sammelpunkte, Routen,
-- Zonen, Notizen), die sich ein- und ausblenden laesst.
CREATE TABLE IF NOT EXISTS map_tactics (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
map_key VARCHAR(50) NOT NULL DEFAULT 'verteron',
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_map_tactics_map (map_key)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- points enthaelt die Stuetzpunkte als JSON-Array [[x,y], ...] mit denselben
-- normierten Koordinaten wie map_markers (TEXT statt JSON, damit auch aeltere
-- MySQL-/MariaDB-Versionen ohne JSON-Typ funktionieren).
CREATE TABLE IF NOT EXISTS map_tactic_shapes (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
tactic_id INT UNSIGNED NOT NULL,
shape_type ENUM('point', 'route', 'area', 'text') NOT NULL,
label VARCHAR(120) NOT NULL DEFAULT '',
color VARCHAR(7) NOT NULL DEFAULT '#c9a227',
points TEXT NOT NULL,
sort_order INT NOT NULL DEFAULT 0,
FOREIGN KEY (tactic_id) REFERENCES map_tactics(id) ON DELETE CASCADE,
INDEX idx_map_shapes_tactic (tactic_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;