mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
* [Servatrice] Log room channel messages and bump schema to 38 * Fixup: show room_channel audit rows and keep migration nullable The log history query returns room_channel rows, but the log tab dropped them. Render them in the room table with an extra Channel column. Also drop the NOT NULL on target_type from the 37->38 migration so migrated schemas match the nullable servatrice.sql definition (and strict-mode ALTERs cannot fail on legacy NULL rows). Update the channel tests to the flag-based privilege model: the admin fixture now carries IsModerator alongside IsAdmin, as the database layer assigns. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
29 lines
No EOL
1.4 KiB
SQL
29 lines
No EOL
1.4 KiB
SQL
-- Servatrice db migration from version 37 to version 38
|
|
|
|
-- Room chat channels.
|
|
--
|
|
-- A room now offers a fixed catalog of named message streams in addition to the
|
|
-- implicit Main channel. Public channels are broadcast to every room member;
|
|
-- restricted channels are only delivered to (and sendable by) members whose
|
|
-- privilege level meets the channel's access level.
|
|
|
|
-- 1. Catalog table, mirroring the config-driven channels of no-DB servers.
|
|
CREATE TABLE IF NOT EXISTS `cockatrice_rooms_channels` (
|
|
`id_room` int(7) unsigned NOT NULL,
|
|
`id_server` tinyint(3) NOT NULL DEFAULT 1,
|
|
`channel_id` varchar(50) NOT NULL,
|
|
`display_name` varchar(50) NOT NULL,
|
|
`access_level` ENUM('public','registered','judge','moderator','admin','developer') NOT NULL DEFAULT 'public',
|
|
PRIMARY KEY (`id_room`, `id_server`, `channel_id`),
|
|
FOREIGN KEY(`id_room`) REFERENCES `cockatrice_rooms`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
|
|
|
-- 2. Audit log: room_channel target type plus a channel column so moderators
|
|
-- can tell which stream a logged message belongs to.
|
|
ALTER TABLE `cockatrice_log`
|
|
MODIFY `target_type` ENUM('room', 'game', 'chat', 'room_channel');
|
|
|
|
ALTER TABLE `cockatrice_log`
|
|
ADD COLUMN `channel` varchar(50) NULL AFTER `target_name`;
|
|
|
|
UPDATE cockatrice_schema_version SET version=38 WHERE version=37; |