Skip to content

Commit

Permalink
DB: Remove unsigned floats and recreate views with utf8mb4 in auth da…
Browse files Browse the repository at this point in the history
…tabase

(cherry picked from commit b18ba61)
  • Loading branch information
Shauren committed Sep 26, 2024
1 parent 6533b61 commit be04c17
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
15 changes: 8 additions & 7 deletions sql/base/auth_database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,7 @@ CREATE TABLE `realmlist` (
`flag` tinyint unsigned NOT NULL DEFAULT '2',
`timezone` tinyint unsigned NOT NULL DEFAULT '0',
`allowedSecurityLevel` tinyint unsigned NOT NULL DEFAULT '0',
`population` float unsigned NOT NULL DEFAULT '0',
`population` float NOT NULL DEFAULT '0',
`gamebuild` int unsigned NOT NULL DEFAULT '56647',
`Region` tinyint unsigned NOT NULL DEFAULT '1',
`Battlegroup` tinyint unsigned NOT NULL DEFAULT '1',
Expand Down Expand Up @@ -3241,7 +3241,8 @@ INSERT INTO `updates` VALUES
('2024_09_11_00_auth.sql','8B810B5EB20D769A50A2D01411BBD065732E4EE6','ARCHIVED','2024-09-11 12:23:18',0),
('2024_09_18_00_auth.sql','073B6E954B585CD81BFADD58CDAD166E85D2653A','ARCHIVED','2024-09-18 10:26:42',0),
('2024_09_18_01_auth.sql','6AE1437E24D4837EB2347ADAA80A4093CA9F6D67','ARCHIVED','2024-09-18 21:30:31',0),
('2024_09_23_00_auth.sql','CBAB00B40360D8942AD1E4EDBE0F0097F3F6FC9B','ARCHIVED','2024-09-23 22:48:10',0);
('2024_09_23_00_auth.sql','CBAB00B40360D8942AD1E4EDBE0F0097F3F6FC9B','ARCHIVED','2024-09-23 22:48:10',0),
('2024_09_26_00_auth.sql','E37C3997FD7851EA360774AC568912846C448272','RELEASED','2024-09-26 18:27:26',0);
/*!40000 ALTER TABLE `updates` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -3352,7 +3353,7 @@ SET character_set_client = @saved_cs_client;
/*!50001 SET character_set_results = utf8mb4 */;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 */
/*!50013 SQL SECURITY INVOKER */
/*!50001 VIEW `vw_log_history` AS select from_unixtime(min(`logs`.`time`)) AS `First Logged`,from_unixtime(max(`logs`.`time`)) AS `Last Logged`,count(0) AS `Occurrences`,`realmlist`.`name` AS `Realm`,`logs`.`type` AS `type`,`logs`.`level` AS `level`,`logs`.`string` AS `string` from (`logs` left join `realmlist` on((`logs`.`realm` = `realmlist`.`id`))) group by `logs`.`string`,`logs`.`type`,`logs`.`realm` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
Expand All @@ -3366,11 +3367,11 @@ SET character_set_client = @saved_cs_client;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
/*!50001 SET character_set_client = utf8mb3 */;
/*!50001 SET character_set_results = utf8mb3 */;
/*!50001 SET collation_connection = utf8mb3_general_ci */;
/*!50001 SET character_set_client = utf8mb4 */;
/*!50001 SET character_set_results = utf8mb4 */;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 */
/*!50013 SQL SECURITY INVOKER */
/*!50001 VIEW `vw_rbac` AS select `t1`.`linkedId` AS `Permission ID`,`t1`.`id` AS `Permission Group`,ifnull(`t2`.`secId`,'linked') AS `Security Level`,`t3`.`name` AS `Permission` from ((`rbac_linked_permissions` `t1` left join `rbac_default_permissions` `t2` on((`t1`.`id` = `t2`.`permissionId`))) left join `rbac_permissions` `t3` on((`t1`.`linkedId` = `t3`.`id`))) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
Expand Down
20 changes: 20 additions & 0 deletions sql/updates/auth/master/2024_09_26_00_auth.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

ALTER TABLE `realmlist` MODIFY `population` float NOT NULL DEFAULT '0';

SET NAMES 'utf8mb4' COLLATE 'utf8mb4_unicode_ci'; -- views do not have explicit charset/collation options but record whatever the connection settings were as their own (visible in mysqldump)

DROP VIEW IF EXISTS `vw_log_history`;
DROP VIEW IF EXISTS `vw_rbac`;

CREATE SQL SECURITY INVOKER VIEW `vw_log_history` AS (SELECT FROM_UNIXTIME(MIN(`logs`.`time`)) AS `First Logged` ,FROM_UNIXTIME(MAX(`logs`.`time`)) AS `Last Logged` ,COUNT(*) AS `Occurrences` ,`realmlist`.`name` AS `Realm` ,`logs`.`type` ,`logs`.`level` ,`logs`.`string` FROM `logs` LEFT JOIN realmlist ON `logs`.`realm` = `realmlist`.`id` GROUP BY `logs`.`string`, `logs`.`type`, `logs`.`realm`);

CREATE SQL SECURITY INVOKER VIEW `vw_rbac` AS
(
SELECT `t1`.`linkedId` AS `Permission ID`,
`t1`.`id` AS `Permission Group`,
IFNULL(`t2`.`secId`, 'linked') AS `Security Level`,
`t3`.`name` AS `Permission`
FROM `rbac_linked_permissions` `t1`
LEFT JOIN `rbac_default_permissions` `t2` ON `t1`.`id` = `t2`.`permissionId`
LEFT JOIN `rbac_permissions` `t3` ON `t1`.`linkedId` = `t3`.`id`
);

0 comments on commit be04c17

Please sign in to comment.