mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-21 20:22:48 +00:00
feat(db): permission_grants, permissions and commands given to one account or character
A new table, permission_grants (MySQL migration 96, SQLite 79), and the IPermissionGrants interface with MySQL, SQLite and TestSQL implementations. A row grants (or with deny, takes away) a dashboard permission, a slash command, a permission category or every command up to a GM level, for one account or one character, with an optional expiry, who granted it and when, and a note. Rows are never deleted: removing one sets revoked_at/revoked_by, so the table is also the history. Nothing reads it yet. Check: both migrations run on a fresh and an existing database; DatabaseParityTests PermissionGrants passes against MariaDB (DLU_TEST_MYSQL_HOST) and SQLite gives the same results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
22
migrations/dlu/mysql/96_permission_grants.sql
Normal file
22
migrations/dlu/mysql/96_permission_grants.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
/* Permissions and slash commands granted to (deny = 0) or taken from (deny = 1) one account or character, on top of
|
||||
what its GM level allows. target_type: 'account' (target_id = accounts.id) or 'character' (target_id = charinfo.id).
|
||||
kind: 'permission' (name = a dashboard permission key), 'command' (name = a slash command's settings name),
|
||||
'permission_group' (name = a permission category) or 'command_group' (name = a GM level: every command up to it).
|
||||
expires_at: 0 for never. Rows are never deleted: removing one sets revoked_at and revoked_by, so the table is also
|
||||
the history of grant changes. granted_by_id is the granting account. */
|
||||
CREATE TABLE IF NOT EXISTS permission_grants (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
target_type VARCHAR(16) NOT NULL,
|
||||
target_id BIGINT NOT NULL,
|
||||
kind VARCHAR(24) NOT NULL,
|
||||
name VARCHAR(64) NOT NULL,
|
||||
deny TINYINT NOT NULL DEFAULT 0,
|
||||
expires_at BIGINT NOT NULL DEFAULT 0,
|
||||
note VARCHAR(255) NOT NULL DEFAULT '',
|
||||
granted_at BIGINT NOT NULL,
|
||||
granted_by_id INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
granted_by VARCHAR(64) NOT NULL DEFAULT '',
|
||||
revoked_at BIGINT NOT NULL DEFAULT 0,
|
||||
revoked_by VARCHAR(64) NOT NULL DEFAULT '',
|
||||
INDEX permission_grants_target (target_type, target_id)
|
||||
);
|
||||
17
migrations/dlu/sqlite/79_permission_grants.sql
Normal file
17
migrations/dlu/sqlite/79_permission_grants.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
/* Permissions and slash commands granted to or taken from one account or character. See the MySQL migration. */
|
||||
CREATE TABLE IF NOT EXISTS permission_grants (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
target_type TEXT NOT NULL,
|
||||
target_id BIGINT NOT NULL,
|
||||
kind TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
deny INTEGER NOT NULL DEFAULT 0,
|
||||
expires_at BIGINT NOT NULL DEFAULT 0,
|
||||
note TEXT NOT NULL DEFAULT '',
|
||||
granted_at BIGINT NOT NULL,
|
||||
granted_by_id INTEGER NOT NULL DEFAULT 0,
|
||||
granted_by TEXT NOT NULL DEFAULT '',
|
||||
revoked_at BIGINT NOT NULL DEFAULT 0,
|
||||
revoked_by TEXT NOT NULL DEFAULT ''
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS permission_grants_target ON permission_grants (target_type, target_id);
|
||||
Reference in New Issue
Block a user