LuminaWebsite/sql/schema.sql
Maaxxs 15098dd530 Add a member list, grouped by role with a configurable roster order
New members.view-gated page (members.php) lists all active guild
members with avatar and roles. Roles get a "Reihenfolge in der
Mitgliederliste" field in admin/role_form.php (roles.roster_order,
nullable int): a role with a number gets its own section on the
page, sorted ascending; members without any such role fall into a
general "Mitglieder" section at the end. A member with several
ordered roles is placed by whichever has the lowest number. Shown
alongside the existing role fields in admin/roles.php too.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-19 14:11:03 +02:00

52 lines
2.3 KiB
SQL

-- Aion2 Gilde - 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,
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;