From 4e12ba5ffe7d4cde73c26da31eff3185eab2c205 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 10 Nov 2023 23:39:21 +0100 Subject: [PATCH] Added other scripts #428 --- .../scripts/1.1.0/1_Achievements_down.sql | 6 + .../scripts/1.1.0/1_Achievements_up.sql | 88 ++++ .../bot_data/scripts/1.1.0/2_Config_down.sql | 8 + .../bot_data/scripts/1.1.0/2_Config_up.sql | 482 ++++++++++++++++++ .../1.1.0/3_ConfigFeatureFlags_down.sql | 4 + .../scripts/1.1.0/3_ConfigFeatureFlags_up.sql | 6 + .../scripts/1.1.3/1_DefaultRole_down.sql | 4 + .../scripts/1.1.3/1_DefaultRole_up.sql | 4 + .../scripts/1.1.7/1_ShortRoleName_down.sql | 4 + .../scripts/1.1.7/1_ShortRoleName_up.sql | 53 ++ .../scripts/1.1.7/2_FixUpdates_down.sql | 10 + .../scripts/1.1.7/2_FixUpdates_up.sql | 210 ++++++++ .../1.1.9/1_ShortRoleNameOnlyHighest_down.sql | 9 + .../1.1.9/1_ShortRoleNameOnlyHighest_up.sql | 134 +++++ .../scripts/1.2.0/1_FixUserHistory_down.sql | 9 + .../scripts/1.2.0/1_FixUserHistory_up.sql | 52 ++ .../scripts/1.2.0/2_Birthday_down.sql | 19 + .../bot_data/scripts/1.2.0/2_Birthday_up.sql | 190 +++++++ .../1.2.0/3_SteamSpecialOffer_down.sql | 12 + .../scripts/1.2.0/3_SteamSpecialOffer_up.sql | 23 + .../1.2.0/4_MaxSteamOfferCount_down.sql | 9 + .../scripts/1.2.0/4_MaxSteamOfferCount_up.sql | 84 +++ .../scripts/1.2.0/5_MaintenanceMode_down.sql | 9 + .../scripts/1.2.0/5_MaintenanceMode_up.sql | 84 +++ 24 files changed, 1513 insertions(+) create mode 100644 bot/src/bot_data/scripts/1.1.0/1_Achievements_down.sql create mode 100644 bot/src/bot_data/scripts/1.1.0/1_Achievements_up.sql create mode 100644 bot/src/bot_data/scripts/1.1.0/2_Config_down.sql create mode 100644 bot/src/bot_data/scripts/1.1.0/2_Config_up.sql create mode 100644 bot/src/bot_data/scripts/1.1.0/3_ConfigFeatureFlags_down.sql create mode 100644 bot/src/bot_data/scripts/1.1.0/3_ConfigFeatureFlags_up.sql create mode 100644 bot/src/bot_data/scripts/1.1.3/1_DefaultRole_down.sql create mode 100644 bot/src/bot_data/scripts/1.1.3/1_DefaultRole_up.sql create mode 100644 bot/src/bot_data/scripts/1.1.7/1_ShortRoleName_down.sql create mode 100644 bot/src/bot_data/scripts/1.1.7/1_ShortRoleName_up.sql create mode 100644 bot/src/bot_data/scripts/1.1.7/2_FixUpdates_down.sql create mode 100644 bot/src/bot_data/scripts/1.1.7/2_FixUpdates_up.sql create mode 100644 bot/src/bot_data/scripts/1.1.9/1_ShortRoleNameOnlyHighest_down.sql create mode 100644 bot/src/bot_data/scripts/1.1.9/1_ShortRoleNameOnlyHighest_up.sql create mode 100644 bot/src/bot_data/scripts/1.2.0/1_FixUserHistory_down.sql create mode 100644 bot/src/bot_data/scripts/1.2.0/1_FixUserHistory_up.sql create mode 100644 bot/src/bot_data/scripts/1.2.0/2_Birthday_down.sql create mode 100644 bot/src/bot_data/scripts/1.2.0/2_Birthday_up.sql create mode 100644 bot/src/bot_data/scripts/1.2.0/3_SteamSpecialOffer_down.sql create mode 100644 bot/src/bot_data/scripts/1.2.0/3_SteamSpecialOffer_up.sql create mode 100644 bot/src/bot_data/scripts/1.2.0/4_MaxSteamOfferCount_down.sql create mode 100644 bot/src/bot_data/scripts/1.2.0/4_MaxSteamOfferCount_up.sql create mode 100644 bot/src/bot_data/scripts/1.2.0/5_MaintenanceMode_down.sql create mode 100644 bot/src/bot_data/scripts/1.2.0/5_MaintenanceMode_up.sql diff --git a/bot/src/bot_data/scripts/1.1.0/1_Achievements_down.sql b/bot/src/bot_data/scripts/1.1.0/1_Achievements_down.sql new file mode 100644 index 00000000..186492f9 --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.0/1_Achievements_down.sql @@ -0,0 +1,6 @@ +DROP TABLE `Achievements`; + +ALTER TABLE Users DROP COLUMN MessageCount; + +ALTER TABLE Users DROP COLUMN ReactionCount; + diff --git a/bot/src/bot_data/scripts/1.1.0/1_Achievements_up.sql b/bot/src/bot_data/scripts/1.1.0/1_Achievements_up.sql new file mode 100644 index 00000000..9ee7e25b --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.0/1_Achievements_up.sql @@ -0,0 +1,88 @@ +CREATE TABLE IF NOT EXISTS `Achievements` +( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `Name` VARCHAR(255) NOT NULL, + `Description` VARCHAR(255) NOT NULL, + `Attribute` VARCHAR(255) NOT NULL, + `Operator` VARCHAR(255) NOT NULL, + `Value` VARCHAR(255) NOT NULL, + `ServerId` BIGINT, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (`Id`), + FOREIGN KEY (`ServerId`) REFERENCES `Servers` (`ServerId`) +); + + + +CREATE TABLE IF NOT EXISTS `AchievementsHistory` +( + `Id` BIGINT(20) NOT NULL, + `Name` VARCHAR(255) NOT NULL, + `Description` VARCHAR(255) NOT NULL, + `Attribute` VARCHAR(255) NOT NULL, + `Operator` VARCHAR(255) NOT NULL, + `Value` VARCHAR(255) NOT NULL, + `ServerId` BIGINT, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +); + + + +CREATE TABLE IF NOT EXISTS `UserGotAchievements` +( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `UserId` BIGINT, + `AchievementId` BIGINT, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (`Id`), + FOREIGN KEY (`UserId`) REFERENCES `Users` (`UserId`), + FOREIGN KEY (`AchievementId`) REFERENCES `Achievements` (`Id`) +); + + +ALTER TABLE Users + ADD MessageCount BIGINT NOT NULL DEFAULT 0 AFTER XP; + +ALTER TABLE Users + ADD ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP; + +ALTER TABLE UsersHistory + ADD MessageCount BIGINT NOT NULL DEFAULT 0 AFTER XP; + +ALTER TABLE UsersHistory + ADD ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP; + +DROP TRIGGER IF EXISTS `TR_AchievementsUpdate`; + + +CREATE TRIGGER `TR_AchievementsUpdate` + AFTER UPDATE + ON `Achievements` + FOR EACH ROW +BEGIN + INSERT INTO `AchievementsHistory` (`Id`, `Name`, `Description`, `Attribute`, `Operator`, `Value`, `ServerId`, + `DateFrom`, `DateTo`) + VALUES (OLD.Id, OLD.Name, OLD.Description, OLD.Attribute, OLD.Operator, OLD.Value, OLD.ServerId, OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END; + + +DROP TRIGGER IF EXISTS `TR_AchievementsDelete`; + + +CREATE TRIGGER `TR_AchievementsDelete` + AFTER DELETE + ON `Achievements` + FOR EACH ROW +BEGIN + INSERT INTO `AchievementsHistory` (`Id`, `Name`, `Description`, `Attribute`, `Operator`, `Value`, `ServerId`, + `Deleted`, `DateFrom`, `DateTo`) + VALUES (OLD.Id, OLD.Name, OLD.Description, OLD.Attribute, OLD.Operator, OLD.Value, OLD.ServerId, TRUE, + OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)); +END; + + diff --git a/bot/src/bot_data/scripts/1.1.0/2_Config_down.sql b/bot/src/bot_data/scripts/1.1.0/2_Config_down.sql new file mode 100644 index 00000000..54ec30b8 --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.0/2_Config_down.sql @@ -0,0 +1,8 @@ +DROP TABLE `CFG_Server`; + +DROP TABLE `CFG_Technician`; + +DROP TABLE `CFG_TechnicianPingUrls`; + +DROP TABLE `CFG_TechnicianIds`; + diff --git a/bot/src/bot_data/scripts/1.1.0/2_Config_up.sql b/bot/src/bot_data/scripts/1.1.0/2_Config_up.sql new file mode 100644 index 00000000..28fa6f2d --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.0/2_Config_up.sql @@ -0,0 +1,482 @@ +CREATE TABLE IF NOT EXISTS `CFG_Server` +( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `MessageDeleteTimer` BIGINT NOT NULL DEFAULT 6, + `NotificationChatId` BIGINT NOT NULL, + `MaxVoiceStateHours` BIGINT NOT NULL DEFAULT 6, + `XpPerMessage` BIGINT NOT NULL DEFAULT 1, + `XpPerReaction` BIGINT NOT NULL DEFAULT 1, + `MaxMessageXpPerHour` BIGINT NOT NULL DEFAULT 20, + `XpPerOntimeHour` BIGINT NOT NULL DEFAULT 10, + `XpPerEventParticipation` BIGINT NOT NULL DEFAULT 10, + `XpPerAchievement` BIGINT NOT NULL DEFAULT 10, + `AFKCommandChannelId` BIGINT NOT NULL, + `HelpVoiceChannelId` BIGINT NOT NULL, + `TeamChannelId` BIGINT NOT NULL, + `LoginMessageChannelId` BIGINT NOT NULL, + `ServerId` BIGINT NOT NULL, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (`Id`), + FOREIGN KEY (`ServerId`) REFERENCES `Servers` (`ServerId`) +); + + + +CREATE TABLE IF NOT EXISTS `CFG_ServerAFKChannelIds` +( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `ChannelId` BIGINT NOT NULL, + `ServerId` BIGINT NOT NULL, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (`Id`), + FOREIGN KEY (`ServerId`) REFERENCES `Servers` (`ServerId`) +); + + + +CREATE TABLE IF NOT EXISTS `CFG_ServerTeamRoleIds` +( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `RoleId` BIGINT NOT NULL, + `TeamMemberType` ENUM ('Moderator', 'Admin') NOT NULL, + `ServerId` BIGINT NOT NULL, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (`Id`), + FOREIGN KEY (`ServerId`) REFERENCES `Servers` (`ServerId`) +); + + + +CREATE TABLE IF NOT EXISTS `CFG_Technician` +( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `HelpCommandReferenceUrl` VARCHAR(255) NOT NULL, + `WaitForRestart` BIGINT NOT NULL DEFAULT 8, + `WaitForShutdown` BIGINT NOT NULL DEFAULT 8, + `CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (`Id`) +); + + + +CREATE TABLE IF NOT EXISTS `CFG_TechnicianPingUrls` +( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `URL` VARCHAR(255) NOT NULL, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (`Id`) +); + + + +CREATE TABLE IF NOT EXISTS `CFG_TechnicianIds` +( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `TechnicianId` BIGINT NOT NULL, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (`Id`) +); + + +CREATE TABLE IF NOT EXISTS `CFG_ServerHistory` +( + `Id` BIGINT(20) NOT NULL, + `MessageDeleteTimer` BIGINT NOT NULL DEFAULT 6, + `NotificationChatId` BIGINT NOT NULL, + `MaxVoiceStateHours` BIGINT NOT NULL DEFAULT 6, + `XpPerMessage` BIGINT NOT NULL DEFAULT 1, + `XpPerReaction` BIGINT NOT NULL DEFAULT 1, + `MaxMessageXpPerHour` BIGINT NOT NULL DEFAULT 20, + `XpPerOntimeHour` BIGINT NOT NULL DEFAULT 10, + `XpPerEventParticipation` BIGINT NOT NULL DEFAULT 10, + `XpPerAchievement` BIGINT NOT NULL DEFAULT 10, + `AFKCommandChannelId` BIGINT NOT NULL, + `HelpVoiceChannelId` BIGINT NOT NULL, + `TeamChannelId` BIGINT NOT NULL, + `LoginMessageChannelId` BIGINT NOT NULL, + `DefaultRoleId` BIGINT NULL, + `ShortRoleNameSetOnlyHighest` BOOLEAN NOT NULL DEFAULT FALSE, + `FeatureFlags` JSON NULL DEFAULT ('{}'), + `ServerId` BIGINT NOT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerUpdate`;; + +CREATE TRIGGER `TR_CFG_ServerUpdate` + AFTER UPDATE + ON `CFG_Server` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerHistory` (`Id`, + `MessageDeleteTimer`, + `NotificationChatId`, + `MaxVoiceStateHours`, + `XpPerMessage`, + `XpPerReaction`, + `MaxMessageXpPerHour`, + `XpPerOntimeHour`, + `XpPerEventParticipation`, + `XpPerAchievement`, + `AFKCommandChannelId`, + `HelpVoiceChannelId`, + `TeamChannelId`, + `LoginMessageChannelId`, + `DefaultRoleId`, + `ShortRoleNameSetOnlyHighest`, + `FeatureFlags`, + `ServerId`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.MessageDeleteTimer, + OLD.NotificationChatId, + OLD.MaxVoiceStateHours, + OLD.XpPerMessage, + OLD.XpPerReaction, + OLD.MaxMessageXpPerHour, + OLD.XpPerOntimeHour, + OLD.XpPerEventParticipation, + OLD.XpPerAchievement, + OLD.AFKCommandChannelId, + OLD.HelpVoiceChannelId, + OLD.TeamChannelId, + OLD.LoginMessageChannelId, + OLD.DefaultRoleId, + OLD.ShortRoleNameSetOnlyHighest, + OLD.FeatureFlags, + OLD.ServerId, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`;; + +CREATE TRIGGER `TR_CFG_ServerDelete` + AFTER DELETE + ON `CFG_Server` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerHistory` (`Id`, + `MessageDeleteTimer`, + `NotificationChatId`, + `MaxVoiceStateHours`, + `XpPerMessage`, + `XpPerReaction`, + `MaxMessageXpPerHour`, + `XpPerOntimeHour`, + `XpPerEventParticipation`, + `XpPerAchievement`, + `AFKCommandChannelId`, + `HelpVoiceChannelId`, + `TeamChannelId`, + `LoginMessageChannelId`, + `DefaultRoleId`, + `ShortRoleNameSetOnlyHighest`, + `ServerId`, + `FeatureFlags`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.MessageDeleteTimer, + OLD.NotificationChatId, + OLD.MaxVoiceStateHours, + OLD.XpPerMessage, + OLD.XpPerReaction, + OLD.MaxMessageXpPerHour, + OLD.XpPerOntimeHour, + OLD.XpPerEventParticipation, + OLD.XpPerAchievement, + OLD.AFKCommandChannelId, + OLD.HelpVoiceChannelId, + OLD.TeamChannelId, + OLD.LoginMessageChannelId, + OLD.DefaultRoleId, + OLD.ShortRoleNameSetOnlyHighest, + OLD.FeatureFlags, + OLD.ServerId, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +CREATE TABLE IF NOT EXISTS `CFG_ServerAFKChannelIdsHistory` +( + `Id` BIGINT(20) NOT NULL, + `ChannelId` BIGINT NOT NULL, + `ServerId` BIGINT NOT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerAFKChannelIdsUpdate`;; + +CREATE TRIGGER `TR_CFG_ServerAFKChannelIdsUpdate` + AFTER UPDATE + ON `CFG_ServerAFKChannelIds` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerAFKChannelIdsHistory` (`Id`, + `ChannelId`, + `ServerId`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.ChannelId, + OLD.ServerId, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerAFKChannelIdsDelete`;; + +CREATE TRIGGER `TR_CFG_ServerAFKChannelIdsDelete` + AFTER DELETE + ON `CFG_ServerAFKChannelIds` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerAFKChannelIdsHistory` (`Id`, + `ChannelId`, + `ServerId`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.ChannelId, + OLD.ServerId, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +CREATE TABLE IF NOT EXISTS `CFG_ServerTeamRoleIdsHistory` +( + `Id` BIGINT(20) NOT NULL, + `RoleId` BIGINT NOT NULL, + `TeamMemberType` ENUM ('Moderator', 'Admin') NOT NULL, + `ServerId` BIGINT NOT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerTeamRoleIdsUpdate`;; + +CREATE TRIGGER `TR_CFG_ServerTeamRoleIdsUpdate` + AFTER UPDATE + ON `CFG_ServerTeamRoleIds` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerTeamRoleIdsHistory` (`Id`, + `RoleId`, + `TeamMemberType`, + `ServerId`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.RoleId, + OLD.TeamMemberType, + OLD.ServerId, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerTeamRoleIdsDelete`;; + +CREATE TRIGGER `TR_CFG_ServerTeamRoleIdsDelete` + AFTER DELETE + ON `CFG_ServerTeamRoleIds` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerTeamRoleIdsHistory` (`Id`, + `RoleId`, + `TeamMemberType`, + `ServerId`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.RoleId, + OLD.TeamMemberType, + OLD.ServerId, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +CREATE TABLE IF NOT EXISTS `CFG_TechnicianHistory` +( + `Id` BIGINT(20) NOT NULL, + `HelpCommandReferenceUrl` VARCHAR(255) NOT NULL, + `WaitForRestart` BIGINT NOT NULL DEFAULT 8, + `WaitForShutdown` BIGINT NOT NULL DEFAULT 8, + `CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000, + `MaxSteamOfferCount` BIGINT NOT NULL DEFAULT 250, + `Maintenance` BOOLEAN DEFAULT FALSE, + `FeatureFlags` JSON NULL DEFAULT ('{}'), + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianUpdate`;; + +CREATE TRIGGER `TR_CFG_TechnicianUpdate` + AFTER UPDATE + ON `CFG_Technician` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianHistory` (`Id`, + `HelpCommandReferenceUrl`, + `WaitForRestart`, + `WaitForShutdown`, + `CacheMaxMessages`, + `MaxSteamOfferCount`, + `Maintenance`, + `FeatureFlags`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.HelpCommandReferenceUrl, + OLD.WaitForRestart, + OLD.WaitForShutdown, + OLD.CacheMaxMessages, + OLD.MaxSteamOfferCount, + OLD.Maintenance, + OLD.FeatureFlags, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianDelete`;; + +CREATE TRIGGER `TR_CFG_TechnicianDelete` + AFTER DELETE + ON `CFG_Technician` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianHistory` (`Id`, + `HelpCommandReferenceUrl`, + `WaitForRestart`, + `WaitForShutdown`, + `CacheMaxMessages`, + `MaxSteamOfferCount`, + `Maintenance`, + `FeatureFlags`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.HelpCommandReferenceUrl, + OLD.WaitForRestart, + OLD.WaitForShutdown, + OLD.CacheMaxMessages, + OLD.MaxSteamOfferCount, + OLD.Maintenance, + OLD.FeatureFlags, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +CREATE TABLE IF NOT EXISTS `CFG_TechnicianIdsHistory` +( + `Id` BIGINT(20) NOT NULL, + `TechnicianId` BIGINT NOT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianIdsUpdate`;; + +CREATE TRIGGER `TR_CFG_TechnicianIdsUpdate` + AFTER UPDATE + ON `CFG_TechnicianIds` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianIdsHistory` (`Id`, + `TechnicianId`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.TechnicianId, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianIdsDelete`;; + +CREATE TRIGGER `TR_CFG_TechnicianIdsDelete` + AFTER DELETE + ON `CFG_TechnicianIds` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianIdsHistory` (`Id`, + `TechnicianId`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.TechnicianId, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +CREATE TABLE IF NOT EXISTS `CFG_TechnicianPingUrlsHistory` +( + `Id` BIGINT(20) NOT NULL, + `URL` VARCHAR(255) NOT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianPingUrlsUpdate`;; + +CREATE TRIGGER `TR_CFG_TechnicianPingUrlsUpdate` + AFTER UPDATE + ON `CFG_TechnicianPingUrls` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianPingUrlsHistory` (`Id`, + `URL`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.URL, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianPingUrlsDelete`;; + +CREATE TRIGGER `TR_CFG_TechnicianPingUrlsDelete` + AFTER DELETE + ON `CFG_TechnicianPingUrls` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianPingUrlsHistory` (`Id`, + `URL`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.URL, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + diff --git a/bot/src/bot_data/scripts/1.1.0/3_ConfigFeatureFlags_down.sql b/bot/src/bot_data/scripts/1.1.0/3_ConfigFeatureFlags_down.sql new file mode 100644 index 00000000..9970595f --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.0/3_ConfigFeatureFlags_down.sql @@ -0,0 +1,4 @@ +ALTER TABLE CFG_Technician DROP COLUMN FeatureFlags; + +ALTER TABLE CFG_Server DROP COLUMN FeatureFlags; + diff --git a/bot/src/bot_data/scripts/1.1.0/3_ConfigFeatureFlags_up.sql b/bot/src/bot_data/scripts/1.1.0/3_ConfigFeatureFlags_up.sql new file mode 100644 index 00000000..8b81f4b4 --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.0/3_ConfigFeatureFlags_up.sql @@ -0,0 +1,6 @@ +ALTER TABLE CFG_Technician + ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER CacheMaxMessages; + +ALTER TABLE CFG_Server + ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER LoginMessageChannelId; + diff --git a/bot/src/bot_data/scripts/1.1.3/1_DefaultRole_down.sql b/bot/src/bot_data/scripts/1.1.3/1_DefaultRole_down.sql new file mode 100644 index 00000000..f465a5dc --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.3/1_DefaultRole_down.sql @@ -0,0 +1,4 @@ +ALTER TABLE CFG_Server + DROP COLUMN DefaultRoleId; + + diff --git a/bot/src/bot_data/scripts/1.1.3/1_DefaultRole_up.sql b/bot/src/bot_data/scripts/1.1.3/1_DefaultRole_up.sql new file mode 100644 index 00000000..97b1c1ec --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.3/1_DefaultRole_up.sql @@ -0,0 +1,4 @@ +ALTER TABLE CFG_Server + ADD DefaultRoleId BIGINT NULL AFTER LoginMessageChannelId; + + diff --git a/bot/src/bot_data/scripts/1.1.7/1_ShortRoleName_down.sql b/bot/src/bot_data/scripts/1.1.7/1_ShortRoleName_down.sql new file mode 100644 index 00000000..b15a3e0e --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.7/1_ShortRoleName_down.sql @@ -0,0 +1,4 @@ +DROP TABLE `ShortRoleNames`; + +DROP TABLE `ShortRoleNamesHistory`; + diff --git a/bot/src/bot_data/scripts/1.1.7/1_ShortRoleName_up.sql b/bot/src/bot_data/scripts/1.1.7/1_ShortRoleName_up.sql new file mode 100644 index 00000000..ee0f9ef4 --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.7/1_ShortRoleName_up.sql @@ -0,0 +1,53 @@ +CREATE TABLE IF NOT EXISTS `ShortRoleNames` +( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `ShortName` VARCHAR(255) NOT NULL, + `DiscordRoleId` BIGINT NOT NULL, + `Position` ENUM ('before', 'after') NOT NULL, + `ServerId` BIGINT, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (`Id`), + FOREIGN KEY (`ServerId`) REFERENCES `Servers` (`ServerId`) +); + + +CREATE TABLE IF NOT EXISTS `ShortRoleNamesHistory` +( + `Id` BIGINT(20) NOT NULL, + `ShortName` VARCHAR(64) DEFAULT NULL, + `DiscordRoleId` BIGINT(20) NOT NULL, + `Position` ENUM ('Before', 'After') NOT NULL, + `ServerId` BIGINT(20) DEFAULT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_ShortRoleNamesUpdate`;; + +CREATE TRIGGER `TR_ShortRoleNamesUpdate` + AFTER UPDATE + ON `ShortRoleNames` + FOR EACH ROW +BEGIN + INSERT INTO `ShortRoleNamesHistory` (`Id`, `ShortName`, `DiscordRoleId`, `Position`, `ServerId`, `DateFrom`, + `DateTo`) + VALUES (OLD.Id, OLD.ShortName, OLD.DiscordRoleId, OLD.Position, OLD.ServerId, OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_ShortRoleNamesDelete`;; + +CREATE TRIGGER `TR_ShortRoleNamesDelete` + AFTER DELETE + ON `ShortRoleNames` + FOR EACH ROW +BEGIN + INSERT INTO `ShortRoleNamesHistory` (`Id`, `ShortName`, `DiscordRoleId`, `Position`, `ServerId`, `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, OLD.ShortName, OLD.DiscordRoleId, OLD.Position, OLD.ServerId, TRUE, OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + diff --git a/bot/src/bot_data/scripts/1.1.7/2_FixUpdates_down.sql b/bot/src/bot_data/scripts/1.1.7/2_FixUpdates_down.sql new file mode 100644 index 00000000..6ddb34a4 --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.7/2_FixUpdates_down.sql @@ -0,0 +1,10 @@ +ALTER TABLE CFG_ServerHistory + DROP COLUMN DefaultRoleId; + + +ALTER TABLE CFG_TechnicianHistory + DROP COLUMN FeatureFlags; + +ALTER TABLE CFG_ServerHistory + DROP COLUMN FeatureFlags; + diff --git a/bot/src/bot_data/scripts/1.1.7/2_FixUpdates_up.sql b/bot/src/bot_data/scripts/1.1.7/2_FixUpdates_up.sql new file mode 100644 index 00000000..463b9b69 --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.7/2_FixUpdates_up.sql @@ -0,0 +1,210 @@ +ALTER TABLE CFG_ServerHistory + ADD DefaultRoleId BIGINT NULL AFTER LoginMessageChannelId; + + +ALTER TABLE CFG_TechnicianHistory + ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER CacheMaxMessages; + +ALTER TABLE CFG_ServerHistory + ADD FeatureFlags JSON NULL DEFAULT ('{}') AFTER LoginMessageChannelId; + +CREATE TABLE IF NOT EXISTS `CFG_ServerHistory` +( + `Id` BIGINT(20) NOT NULL, + `MessageDeleteTimer` BIGINT NOT NULL DEFAULT 6, + `NotificationChatId` BIGINT NOT NULL, + `MaxVoiceStateHours` BIGINT NOT NULL DEFAULT 6, + `XpPerMessage` BIGINT NOT NULL DEFAULT 1, + `XpPerReaction` BIGINT NOT NULL DEFAULT 1, + `MaxMessageXpPerHour` BIGINT NOT NULL DEFAULT 20, + `XpPerOntimeHour` BIGINT NOT NULL DEFAULT 10, + `XpPerEventParticipation` BIGINT NOT NULL DEFAULT 10, + `XpPerAchievement` BIGINT NOT NULL DEFAULT 10, + `AFKCommandChannelId` BIGINT NOT NULL, + `HelpVoiceChannelId` BIGINT NOT NULL, + `TeamChannelId` BIGINT NOT NULL, + `LoginMessageChannelId` BIGINT NOT NULL, + `DefaultRoleId` BIGINT NULL, + `ShortRoleNameSetOnlyHighest` BOOLEAN NOT NULL DEFAULT FALSE, + `FeatureFlags` JSON NULL DEFAULT ('{}'), + `ServerId` BIGINT NOT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerUpdate`;; + +CREATE TRIGGER `TR_CFG_ServerUpdate` + AFTER UPDATE + ON `CFG_Server` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerHistory` (`Id`, + `MessageDeleteTimer`, + `NotificationChatId`, + `MaxVoiceStateHours`, + `XpPerMessage`, + `XpPerReaction`, + `MaxMessageXpPerHour`, + `XpPerOntimeHour`, + `XpPerEventParticipation`, + `XpPerAchievement`, + `AFKCommandChannelId`, + `HelpVoiceChannelId`, + `TeamChannelId`, + `LoginMessageChannelId`, + `DefaultRoleId`, + `ShortRoleNameSetOnlyHighest`, + `FeatureFlags`, + `ServerId`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.MessageDeleteTimer, + OLD.NotificationChatId, + OLD.MaxVoiceStateHours, + OLD.XpPerMessage, + OLD.XpPerReaction, + OLD.MaxMessageXpPerHour, + OLD.XpPerOntimeHour, + OLD.XpPerEventParticipation, + OLD.XpPerAchievement, + OLD.AFKCommandChannelId, + OLD.HelpVoiceChannelId, + OLD.TeamChannelId, + OLD.LoginMessageChannelId, + OLD.DefaultRoleId, + OLD.ShortRoleNameSetOnlyHighest, + OLD.FeatureFlags, + OLD.ServerId, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`;; + +CREATE TRIGGER `TR_CFG_ServerDelete` + AFTER DELETE + ON `CFG_Server` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerHistory` (`Id`, + `MessageDeleteTimer`, + `NotificationChatId`, + `MaxVoiceStateHours`, + `XpPerMessage`, + `XpPerReaction`, + `MaxMessageXpPerHour`, + `XpPerOntimeHour`, + `XpPerEventParticipation`, + `XpPerAchievement`, + `AFKCommandChannelId`, + `HelpVoiceChannelId`, + `TeamChannelId`, + `LoginMessageChannelId`, + `DefaultRoleId`, + `ShortRoleNameSetOnlyHighest`, + `ServerId`, + `FeatureFlags`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.MessageDeleteTimer, + OLD.NotificationChatId, + OLD.MaxVoiceStateHours, + OLD.XpPerMessage, + OLD.XpPerReaction, + OLD.MaxMessageXpPerHour, + OLD.XpPerOntimeHour, + OLD.XpPerEventParticipation, + OLD.XpPerAchievement, + OLD.AFKCommandChannelId, + OLD.HelpVoiceChannelId, + OLD.TeamChannelId, + OLD.LoginMessageChannelId, + OLD.DefaultRoleId, + OLD.ShortRoleNameSetOnlyHighest, + OLD.FeatureFlags, + OLD.ServerId, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +CREATE TABLE IF NOT EXISTS `CFG_TechnicianHistory` +( + `Id` BIGINT(20) NOT NULL, + `HelpCommandReferenceUrl` VARCHAR(255) NOT NULL, + `WaitForRestart` BIGINT NOT NULL DEFAULT 8, + `WaitForShutdown` BIGINT NOT NULL DEFAULT 8, + `CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000, + `MaxSteamOfferCount` BIGINT NOT NULL DEFAULT 250, + `Maintenance` BOOLEAN DEFAULT FALSE, + `FeatureFlags` JSON NULL DEFAULT ('{}'), + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianUpdate`;; + +CREATE TRIGGER `TR_CFG_TechnicianUpdate` + AFTER UPDATE + ON `CFG_Technician` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianHistory` (`Id`, + `HelpCommandReferenceUrl`, + `WaitForRestart`, + `WaitForShutdown`, + `CacheMaxMessages`, + `MaxSteamOfferCount`, + `Maintenance`, + `FeatureFlags`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.HelpCommandReferenceUrl, + OLD.WaitForRestart, + OLD.WaitForShutdown, + OLD.CacheMaxMessages, + OLD.MaxSteamOfferCount, + OLD.Maintenance, + OLD.FeatureFlags, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianDelete`;; + +CREATE TRIGGER `TR_CFG_TechnicianDelete` + AFTER DELETE + ON `CFG_Technician` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianHistory` (`Id`, + `HelpCommandReferenceUrl`, + `WaitForRestart`, + `WaitForShutdown`, + `CacheMaxMessages`, + `MaxSteamOfferCount`, + `Maintenance`, + `FeatureFlags`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.HelpCommandReferenceUrl, + OLD.WaitForRestart, + OLD.WaitForShutdown, + OLD.CacheMaxMessages, + OLD.MaxSteamOfferCount, + OLD.Maintenance, + OLD.FeatureFlags, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + diff --git a/bot/src/bot_data/scripts/1.1.9/1_ShortRoleNameOnlyHighest_down.sql b/bot/src/bot_data/scripts/1.1.9/1_ShortRoleNameOnlyHighest_down.sql new file mode 100644 index 00000000..8ccceb05 --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.9/1_ShortRoleNameOnlyHighest_down.sql @@ -0,0 +1,9 @@ +ALTER TABLE CFG_Server + DROP COLUMN ShortRoleNameSetOnlyHighest; + + + +ALTER TABLE CFG_ServerHistory + DROP COLUMN ShortRoleNameSetOnlyHighest; + + diff --git a/bot/src/bot_data/scripts/1.1.9/1_ShortRoleNameOnlyHighest_up.sql b/bot/src/bot_data/scripts/1.1.9/1_ShortRoleNameOnlyHighest_up.sql new file mode 100644 index 00000000..4ef565fa --- /dev/null +++ b/bot/src/bot_data/scripts/1.1.9/1_ShortRoleNameOnlyHighest_up.sql @@ -0,0 +1,134 @@ +ALTER TABLE CFG_Server + ADD ShortRoleNameSetOnlyHighest BOOLEAN NOT NULL DEFAULT FALSE AFTER DefaultRoleId; + + + +ALTER TABLE CFG_ServerHistory + ADD ShortRoleNameSetOnlyHighest BOOLEAN NOT NULL DEFAULT FALSE AFTER DefaultRoleId; + + +CREATE TABLE IF NOT EXISTS `CFG_ServerHistory` +( + `Id` BIGINT(20) NOT NULL, + `MessageDeleteTimer` BIGINT NOT NULL DEFAULT 6, + `NotificationChatId` BIGINT NOT NULL, + `MaxVoiceStateHours` BIGINT NOT NULL DEFAULT 6, + `XpPerMessage` BIGINT NOT NULL DEFAULT 1, + `XpPerReaction` BIGINT NOT NULL DEFAULT 1, + `MaxMessageXpPerHour` BIGINT NOT NULL DEFAULT 20, + `XpPerOntimeHour` BIGINT NOT NULL DEFAULT 10, + `XpPerEventParticipation` BIGINT NOT NULL DEFAULT 10, + `XpPerAchievement` BIGINT NOT NULL DEFAULT 10, + `AFKCommandChannelId` BIGINT NOT NULL, + `HelpVoiceChannelId` BIGINT NOT NULL, + `TeamChannelId` BIGINT NOT NULL, + `LoginMessageChannelId` BIGINT NOT NULL, + `DefaultRoleId` BIGINT NULL, + `ShortRoleNameSetOnlyHighest` BOOLEAN NOT NULL DEFAULT FALSE, + `FeatureFlags` JSON NULL DEFAULT ('{}'), + `ServerId` BIGINT NOT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerUpdate`;; + +CREATE TRIGGER `TR_CFG_ServerUpdate` + AFTER UPDATE + ON `CFG_Server` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerHistory` (`Id`, + `MessageDeleteTimer`, + `NotificationChatId`, + `MaxVoiceStateHours`, + `XpPerMessage`, + `XpPerReaction`, + `MaxMessageXpPerHour`, + `XpPerOntimeHour`, + `XpPerEventParticipation`, + `XpPerAchievement`, + `AFKCommandChannelId`, + `HelpVoiceChannelId`, + `TeamChannelId`, + `LoginMessageChannelId`, + `DefaultRoleId`, + `ShortRoleNameSetOnlyHighest`, + `FeatureFlags`, + `ServerId`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.MessageDeleteTimer, + OLD.NotificationChatId, + OLD.MaxVoiceStateHours, + OLD.XpPerMessage, + OLD.XpPerReaction, + OLD.MaxMessageXpPerHour, + OLD.XpPerOntimeHour, + OLD.XpPerEventParticipation, + OLD.XpPerAchievement, + OLD.AFKCommandChannelId, + OLD.HelpVoiceChannelId, + OLD.TeamChannelId, + OLD.LoginMessageChannelId, + OLD.DefaultRoleId, + OLD.ShortRoleNameSetOnlyHighest, + OLD.FeatureFlags, + OLD.ServerId, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`;; + +CREATE TRIGGER `TR_CFG_ServerDelete` + AFTER DELETE + ON `CFG_Server` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerHistory` (`Id`, + `MessageDeleteTimer`, + `NotificationChatId`, + `MaxVoiceStateHours`, + `XpPerMessage`, + `XpPerReaction`, + `MaxMessageXpPerHour`, + `XpPerOntimeHour`, + `XpPerEventParticipation`, + `XpPerAchievement`, + `AFKCommandChannelId`, + `HelpVoiceChannelId`, + `TeamChannelId`, + `LoginMessageChannelId`, + `DefaultRoleId`, + `ShortRoleNameSetOnlyHighest`, + `ServerId`, + `FeatureFlags`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.MessageDeleteTimer, + OLD.NotificationChatId, + OLD.MaxVoiceStateHours, + OLD.XpPerMessage, + OLD.XpPerReaction, + OLD.MaxMessageXpPerHour, + OLD.XpPerOntimeHour, + OLD.XpPerEventParticipation, + OLD.XpPerAchievement, + OLD.AFKCommandChannelId, + OLD.HelpVoiceChannelId, + OLD.TeamChannelId, + OLD.LoginMessageChannelId, + OLD.DefaultRoleId, + OLD.ShortRoleNameSetOnlyHighest, + OLD.FeatureFlags, + OLD.ServerId, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + diff --git a/bot/src/bot_data/scripts/1.2.0/1_FixUserHistory_down.sql b/bot/src/bot_data/scripts/1.2.0/1_FixUserHistory_down.sql new file mode 100644 index 00000000..f19ec313 --- /dev/null +++ b/bot/src/bot_data/scripts/1.2.0/1_FixUserHistory_down.sql @@ -0,0 +1,9 @@ +ALTER TABLE UsersHistory + DROP COLUMN MessageCount; + + + +ALTER TABLE UsersHistory + DROP COLUMN ReactionCount; + + diff --git a/bot/src/bot_data/scripts/1.2.0/1_FixUserHistory_up.sql b/bot/src/bot_data/scripts/1.2.0/1_FixUserHistory_up.sql new file mode 100644 index 00000000..5c600044 --- /dev/null +++ b/bot/src/bot_data/scripts/1.2.0/1_FixUserHistory_up.sql @@ -0,0 +1,52 @@ +ALTER TABLE UsersHistory + ADD COLUMN ReactionCount BIGINT NOT NULL DEFAULT 0 AFTER XP; + +ALTER TABLE UsersHistory + ADD COLUMN MessageCount BIGINT NOT NULL DEFAULT 0 AFTER ReactionCount; + +ALTER TABLE `Users` + CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);; + +ALTER TABLE `Users` + CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);; + +CREATE TABLE IF NOT EXISTS `UsersHistory` +( + `Id` BIGINT(20) NOT NULL, + `DiscordId` BIGINT(20) NOT NULL, + `XP` BIGINT(20) NOT NULL DEFAULT 0, + `ReactionCount` BIGINT(20) NOT NULL DEFAULT 0, + `MessageCount` BIGINT(20) NOT NULL DEFAULT 0, + `Birthday` DATE NULL, + `ServerId` BIGINT(20) DEFAULT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_UsersUpdate`;; + +CREATE TRIGGER `TR_UsersUpdate` + AFTER UPDATE + ON `Users` + FOR EACH ROW +BEGIN + INSERT INTO `UsersHistory` (`Id`, `DiscordId`, `XP`, `ReactionCount`, `MessageCount`, `Birthday`, `ServerId`, + `DateFrom`, `DateTo`) + VALUES (OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ReactionCount, OLD.MessageCount, OLD.Birthday, OLD.ServerId, + OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_UsersDelete`;; + +CREATE TRIGGER `TR_UsersDelete` + AFTER DELETE + ON `Users` + FOR EACH ROW +BEGIN + INSERT INTO `UsersHistory` (`Id`, `DiscordId`, `XP`, `ReactionCount`, `MessageCount`, `Birthday`, `ServerId`, + `Deleted`, `DateFrom`, `DateTo`) + VALUES (OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ReactionCount, OLD.MessageCount, OLD.Birthday, OLD.ServerId, TRUE, + OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)); +END;; + diff --git a/bot/src/bot_data/scripts/1.2.0/2_Birthday_down.sql b/bot/src/bot_data/scripts/1.2.0/2_Birthday_down.sql new file mode 100644 index 00000000..19fc9ae0 --- /dev/null +++ b/bot/src/bot_data/scripts/1.2.0/2_Birthday_down.sql @@ -0,0 +1,19 @@ +ALTER TABLE Users + DROP COLUMN Birthday; + + + +ALTER TABLE UsersHistory + DROP COLUMN Birthday; + + + +ALTER TABLE CFG_Server + DROP COLUMN XpForBirthday; + + + +ALTER TABLE CFG_ServerHistory + DROP COLUMN XpForBirthday; + + diff --git a/bot/src/bot_data/scripts/1.2.0/2_Birthday_up.sql b/bot/src/bot_data/scripts/1.2.0/2_Birthday_up.sql new file mode 100644 index 00000000..8bde9a87 --- /dev/null +++ b/bot/src/bot_data/scripts/1.2.0/2_Birthday_up.sql @@ -0,0 +1,190 @@ +ALTER TABLE Users + ADD Birthday DATE NULL AFTER MessageCount; + + + +ALTER TABLE UsersHistory + ADD Birthday DATE NULL AFTER MessageCount; + + +ALTER TABLE `Users` + CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);; + +ALTER TABLE `Users` + CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);; + +CREATE TABLE IF NOT EXISTS `UsersHistory` +( + `Id` BIGINT(20) NOT NULL, + `DiscordId` BIGINT(20) NOT NULL, + `XP` BIGINT(20) NOT NULL DEFAULT 0, + `ReactionCount` BIGINT(20) NOT NULL DEFAULT 0, + `MessageCount` BIGINT(20) NOT NULL DEFAULT 0, + `Birthday` DATE NULL, + `ServerId` BIGINT(20) DEFAULT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_UsersUpdate`;; + +CREATE TRIGGER `TR_UsersUpdate` + AFTER UPDATE + ON `Users` + FOR EACH ROW +BEGIN + INSERT INTO `UsersHistory` (`Id`, `DiscordId`, `XP`, `ReactionCount`, `MessageCount`, `Birthday`, `ServerId`, + `DateFrom`, `DateTo`) + VALUES (OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ReactionCount, OLD.MessageCount, OLD.Birthday, OLD.ServerId, + OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_UsersDelete`;; + +CREATE TRIGGER `TR_UsersDelete` + AFTER DELETE + ON `Users` + FOR EACH ROW +BEGIN + INSERT INTO `UsersHistory` (`Id`, `DiscordId`, `XP`, `ReactionCount`, `MessageCount`, `Birthday`, `ServerId`, + `Deleted`, `DateFrom`, `DateTo`) + VALUES (OLD.UserId, OLD.DiscordId, OLD.XP, OLD.ReactionCount, OLD.MessageCount, OLD.Birthday, OLD.ServerId, TRUE, + OLD.LastModifiedAt, CURRENT_TIMESTAMP(6)); +END;; + + +ALTER TABLE CFG_Server + ADD XpForBirthday BIGINT(20) NOT NULL DEFAULT 0 AFTER XpPerAchievement; + + + +ALTER TABLE CFG_ServerHistory + ADD XpForBirthday BIGINT(20) NOT NULL DEFAULT 0 AFTER XpPerAchievement; + + +CREATE TABLE IF NOT EXISTS `CFG_ServerHistory` +( + `Id` BIGINT(20) NOT NULL, + `MessageDeleteTimer` BIGINT NOT NULL DEFAULT 6, + `NotificationChatId` BIGINT NOT NULL, + `MaxVoiceStateHours` BIGINT NOT NULL DEFAULT 6, + `XpPerMessage` BIGINT NOT NULL DEFAULT 1, + `XpPerReaction` BIGINT NOT NULL DEFAULT 1, + `MaxMessageXpPerHour` BIGINT NOT NULL DEFAULT 20, + `XpPerOntimeHour` BIGINT NOT NULL DEFAULT 10, + `XpPerEventParticipation` BIGINT NOT NULL DEFAULT 10, + `XpPerAchievement` BIGINT NOT NULL DEFAULT 10, + `AFKCommandChannelId` BIGINT NOT NULL, + `HelpVoiceChannelId` BIGINT NOT NULL, + `TeamChannelId` BIGINT NOT NULL, + `LoginMessageChannelId` BIGINT NOT NULL, + `DefaultRoleId` BIGINT NULL, + `ShortRoleNameSetOnlyHighest` BOOLEAN NOT NULL DEFAULT FALSE, + `FeatureFlags` JSON NULL DEFAULT ('{}'), + `ServerId` BIGINT NOT NULL, + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerUpdate`;; + +CREATE TRIGGER `TR_CFG_ServerUpdate` + AFTER UPDATE + ON `CFG_Server` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerHistory` (`Id`, + `MessageDeleteTimer`, + `NotificationChatId`, + `MaxVoiceStateHours`, + `XpPerMessage`, + `XpPerReaction`, + `MaxMessageXpPerHour`, + `XpPerOntimeHour`, + `XpPerEventParticipation`, + `XpPerAchievement`, + `AFKCommandChannelId`, + `HelpVoiceChannelId`, + `TeamChannelId`, + `LoginMessageChannelId`, + `DefaultRoleId`, + `ShortRoleNameSetOnlyHighest`, + `FeatureFlags`, + `ServerId`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.MessageDeleteTimer, + OLD.NotificationChatId, + OLD.MaxVoiceStateHours, + OLD.XpPerMessage, + OLD.XpPerReaction, + OLD.MaxMessageXpPerHour, + OLD.XpPerOntimeHour, + OLD.XpPerEventParticipation, + OLD.XpPerAchievement, + OLD.AFKCommandChannelId, + OLD.HelpVoiceChannelId, + OLD.TeamChannelId, + OLD.LoginMessageChannelId, + OLD.DefaultRoleId, + OLD.ShortRoleNameSetOnlyHighest, + OLD.FeatureFlags, + OLD.ServerId, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`;; + +CREATE TRIGGER `TR_CFG_ServerDelete` + AFTER DELETE + ON `CFG_Server` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_ServerHistory` (`Id`, + `MessageDeleteTimer`, + `NotificationChatId`, + `MaxVoiceStateHours`, + `XpPerMessage`, + `XpPerReaction`, + `MaxMessageXpPerHour`, + `XpPerOntimeHour`, + `XpPerEventParticipation`, + `XpPerAchievement`, + `AFKCommandChannelId`, + `HelpVoiceChannelId`, + `TeamChannelId`, + `LoginMessageChannelId`, + `DefaultRoleId`, + `ShortRoleNameSetOnlyHighest`, + `ServerId`, + `FeatureFlags`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.MessageDeleteTimer, + OLD.NotificationChatId, + OLD.MaxVoiceStateHours, + OLD.XpPerMessage, + OLD.XpPerReaction, + OLD.MaxMessageXpPerHour, + OLD.XpPerOntimeHour, + OLD.XpPerEventParticipation, + OLD.XpPerAchievement, + OLD.AFKCommandChannelId, + OLD.HelpVoiceChannelId, + OLD.TeamChannelId, + OLD.LoginMessageChannelId, + OLD.DefaultRoleId, + OLD.ShortRoleNameSetOnlyHighest, + OLD.FeatureFlags, + OLD.ServerId, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + diff --git a/bot/src/bot_data/scripts/1.2.0/3_SteamSpecialOffer_down.sql b/bot/src/bot_data/scripts/1.2.0/3_SteamSpecialOffer_down.sql new file mode 100644 index 00000000..e2e1ae6c --- /dev/null +++ b/bot/src/bot_data/scripts/1.2.0/3_SteamSpecialOffer_down.sql @@ -0,0 +1,12 @@ +DROP TABLE `SteamSpecialOffers`; + + +ALTER TABLE CFG_Server + DROP COLUMN ShortRoleNameSetOnlyHighest; + + + +ALTER TABLE CFG_ServerHistory + DROP COLUMN ShortRoleNameSetOnlyHighest; + + diff --git a/bot/src/bot_data/scripts/1.2.0/3_SteamSpecialOffer_up.sql b/bot/src/bot_data/scripts/1.2.0/3_SteamSpecialOffer_up.sql new file mode 100644 index 00000000..f395c825 --- /dev/null +++ b/bot/src/bot_data/scripts/1.2.0/3_SteamSpecialOffer_up.sql @@ -0,0 +1,23 @@ +CREATE TABLE IF NOT EXISTS `SteamSpecialOffers` +( + `Id` BIGINT NOT NULL AUTO_INCREMENT, + `Game` VARCHAR(255) NOT NULL, + `OriginalPrice` FLOAT NOT NULL, + `DiscountPrice` FLOAT NOT NULL, + `DiscountPct` BIGINT NOT NULL, + `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6), + `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (`Id`) +); + + + +ALTER TABLE CFG_Server + ADD COLUMN GameOfferNotificationChatId BIGINT NULL AFTER ShortRoleNameSetOnlyHighest; + + + +ALTER TABLE CFG_ServerHistory + ADD COLUMN GameOfferNotificationChatId BIGINT NULL AFTER ShortRoleNameSetOnlyHighest; + + diff --git a/bot/src/bot_data/scripts/1.2.0/4_MaxSteamOfferCount_down.sql b/bot/src/bot_data/scripts/1.2.0/4_MaxSteamOfferCount_down.sql new file mode 100644 index 00000000..d4884917 --- /dev/null +++ b/bot/src/bot_data/scripts/1.2.0/4_MaxSteamOfferCount_down.sql @@ -0,0 +1,9 @@ +ALTER TABLE CFG_Technician + DROP COLUMN MaxSteamOfferCount; + + + +ALTER TABLE CFG_TechnicianHistory + DROP COLUMN MaxSteamOfferCount; + + diff --git a/bot/src/bot_data/scripts/1.2.0/4_MaxSteamOfferCount_up.sql b/bot/src/bot_data/scripts/1.2.0/4_MaxSteamOfferCount_up.sql new file mode 100644 index 00000000..090a5753 --- /dev/null +++ b/bot/src/bot_data/scripts/1.2.0/4_MaxSteamOfferCount_up.sql @@ -0,0 +1,84 @@ +ALTER TABLE CFG_Technician + ADD MaxSteamOfferCount BIGINT NOT NULL DEFAULT 250 AFTER CacheMaxMessages; + + + +ALTER TABLE CFG_TechnicianHistory + ADD MaxSteamOfferCount BIGINT NOT NULL DEFAULT 250 AFTER CacheMaxMessages; + + +CREATE TABLE IF NOT EXISTS `CFG_TechnicianHistory` +( + `Id` BIGINT(20) NOT NULL, + `HelpCommandReferenceUrl` VARCHAR(255) NOT NULL, + `WaitForRestart` BIGINT NOT NULL DEFAULT 8, + `WaitForShutdown` BIGINT NOT NULL DEFAULT 8, + `CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000, + `MaxSteamOfferCount` BIGINT NOT NULL DEFAULT 250, + `Maintenance` BOOLEAN DEFAULT FALSE, + `FeatureFlags` JSON NULL DEFAULT ('{}'), + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianUpdate`;; + +CREATE TRIGGER `TR_CFG_TechnicianUpdate` + AFTER UPDATE + ON `CFG_Technician` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianHistory` (`Id`, + `HelpCommandReferenceUrl`, + `WaitForRestart`, + `WaitForShutdown`, + `CacheMaxMessages`, + `MaxSteamOfferCount`, + `Maintenance`, + `FeatureFlags`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.HelpCommandReferenceUrl, + OLD.WaitForRestart, + OLD.WaitForShutdown, + OLD.CacheMaxMessages, + OLD.MaxSteamOfferCount, + OLD.Maintenance, + OLD.FeatureFlags, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianDelete`;; + +CREATE TRIGGER `TR_CFG_TechnicianDelete` + AFTER DELETE + ON `CFG_Technician` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianHistory` (`Id`, + `HelpCommandReferenceUrl`, + `WaitForRestart`, + `WaitForShutdown`, + `CacheMaxMessages`, + `MaxSteamOfferCount`, + `Maintenance`, + `FeatureFlags`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.HelpCommandReferenceUrl, + OLD.WaitForRestart, + OLD.WaitForShutdown, + OLD.CacheMaxMessages, + OLD.MaxSteamOfferCount, + OLD.Maintenance, + OLD.FeatureFlags, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + diff --git a/bot/src/bot_data/scripts/1.2.0/5_MaintenanceMode_down.sql b/bot/src/bot_data/scripts/1.2.0/5_MaintenanceMode_down.sql new file mode 100644 index 00000000..a21475b6 --- /dev/null +++ b/bot/src/bot_data/scripts/1.2.0/5_MaintenanceMode_down.sql @@ -0,0 +1,9 @@ +ALTER TABLE CFG_Technician + DROP COLUMN Maintenance; + + + +ALTER TABLE CFG_TechnicianHistory + DROP COLUMN Maintenance; + + diff --git a/bot/src/bot_data/scripts/1.2.0/5_MaintenanceMode_up.sql b/bot/src/bot_data/scripts/1.2.0/5_MaintenanceMode_up.sql new file mode 100644 index 00000000..fb709e98 --- /dev/null +++ b/bot/src/bot_data/scripts/1.2.0/5_MaintenanceMode_up.sql @@ -0,0 +1,84 @@ +ALTER TABLE CFG_Technician + ADD Maintenance BOOLEAN DEFAULT FALSE AFTER MaxSteamOfferCount; + + + +ALTER TABLE CFG_TechnicianHistory + ADD Maintenance BOOLEAN DEFAULT FALSE AFTER MaxSteamOfferCount; + + +CREATE TABLE IF NOT EXISTS `CFG_TechnicianHistory` +( + `Id` BIGINT(20) NOT NULL, + `HelpCommandReferenceUrl` VARCHAR(255) NOT NULL, + `WaitForRestart` BIGINT NOT NULL DEFAULT 8, + `WaitForShutdown` BIGINT NOT NULL DEFAULT 8, + `CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000, + `MaxSteamOfferCount` BIGINT NOT NULL DEFAULT 250, + `Maintenance` BOOLEAN DEFAULT FALSE, + `FeatureFlags` JSON NULL DEFAULT ('{}'), + `Deleted` BOOL DEFAULT FALSE, + `DateFrom` DATETIME(6) NOT NULL, + `DateTo` DATETIME(6) NOT NULL +);; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianUpdate`;; + +CREATE TRIGGER `TR_CFG_TechnicianUpdate` + AFTER UPDATE + ON `CFG_Technician` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianHistory` (`Id`, + `HelpCommandReferenceUrl`, + `WaitForRestart`, + `WaitForShutdown`, + `CacheMaxMessages`, + `MaxSteamOfferCount`, + `Maintenance`, + `FeatureFlags`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.HelpCommandReferenceUrl, + OLD.WaitForRestart, + OLD.WaitForShutdown, + OLD.CacheMaxMessages, + OLD.MaxSteamOfferCount, + OLD.Maintenance, + OLD.FeatureFlags, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; + +DROP TRIGGER IF EXISTS `TR_CFG_TechnicianDelete`;; + +CREATE TRIGGER `TR_CFG_TechnicianDelete` + AFTER DELETE + ON `CFG_Technician` + FOR EACH ROW +BEGIN + INSERT INTO `CFG_TechnicianHistory` (`Id`, + `HelpCommandReferenceUrl`, + `WaitForRestart`, + `WaitForShutdown`, + `CacheMaxMessages`, + `MaxSteamOfferCount`, + `Maintenance`, + `FeatureFlags`, + `Deleted`, + `DateFrom`, + `DateTo`) + VALUES (OLD.Id, + OLD.HelpCommandReferenceUrl, + OLD.WaitForRestart, + OLD.WaitForShutdown, + OLD.CacheMaxMessages, + OLD.MaxSteamOfferCount, + OLD.Maintenance, + OLD.FeatureFlags, + TRUE, + OLD.LastModifiedAt, + CURRENT_TIMESTAMP(6)); +END;; +