Added fix migration #378
This commit is contained in:
parent
d1c79c95b2
commit
5e9cca5b1d
@ -13,6 +13,7 @@ from bot_data.migration.config_feature_flags_migration import ConfigFeatureFlags
|
|||||||
from bot_data.migration.config_migration import ConfigMigration
|
from bot_data.migration.config_migration import ConfigMigration
|
||||||
from bot_data.migration.db_history_migration import DBHistoryMigration
|
from bot_data.migration.db_history_migration import DBHistoryMigration
|
||||||
from bot_data.migration.default_role_migration import DefaultRoleMigration
|
from bot_data.migration.default_role_migration import DefaultRoleMigration
|
||||||
|
from bot_data.migration.fix_updates_migration import FixUpdatesMigration
|
||||||
from bot_data.migration.initial_migration import InitialMigration
|
from bot_data.migration.initial_migration import InitialMigration
|
||||||
from bot_data.migration.level_migration import LevelMigration
|
from bot_data.migration.level_migration import LevelMigration
|
||||||
from bot_data.migration.remove_stats_migration import RemoveStatsMigration
|
from bot_data.migration.remove_stats_migration import RemoveStatsMigration
|
||||||
@ -52,3 +53,4 @@ class StartupMigrationExtension(StartupExtensionABC):
|
|||||||
services.add_transient(MigrationABC, ConfigFeatureFlagsMigration) # 15.08.2023 #334 - 1.1.0
|
services.add_transient(MigrationABC, ConfigFeatureFlagsMigration) # 15.08.2023 #334 - 1.1.0
|
||||||
services.add_transient(MigrationABC, DefaultRoleMigration) # 24.09.2023 #360 - 1.1.3
|
services.add_transient(MigrationABC, DefaultRoleMigration) # 24.09.2023 #360 - 1.1.3
|
||||||
services.add_transient(MigrationABC, ShortRoleNameMigration) # 28.09.2023 #378 - 1.1.7
|
services.add_transient(MigrationABC, ShortRoleNameMigration) # 28.09.2023 #378 - 1.1.7
|
||||||
|
services.add_transient(MigrationABC, FixUpdatesMigration) # 28.09.2023 #378 - 1.1.7
|
||||||
|
@ -24,8 +24,6 @@ class MigrationABC(ABC):
|
|||||||
def downgrade(self):
|
def downgrade(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _exec(self, file: str):
|
def _exec(self, file: str):
|
||||||
path = f"{os.path.dirname(os.path.realpath(__file__))}/db_history_scripts"
|
path = f"{os.path.dirname(os.path.realpath(__file__))}/db_history_scripts"
|
||||||
sql = open(f"{path}/{file}").read()
|
sql = open(f"{path}/{file}").read()
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
CREATE TABLE IF NOT EXISTS `CFG_ServerHistory`
|
CREATE TABLE IF NOT EXISTS `CFG_ServerHistory`
|
||||||
(
|
(
|
||||||
`Id` BIGINT(20) NOT NULL,
|
`Id` BIGINT(20) NOT NULL,
|
||||||
`MessageDeleteTimer` BIGINT NOT NULL DEFAULT 6,
|
`MessageDeleteTimer` BIGINT NOT NULL DEFAULT 6,
|
||||||
`NotificationChatId` BIGINT NOT NULL,
|
`NotificationChatId` BIGINT NOT NULL,
|
||||||
`MaxVoiceStateHours` BIGINT NOT NULL DEFAULT 6,
|
`MaxVoiceStateHours` BIGINT NOT NULL DEFAULT 6,
|
||||||
`XpPerMessage` BIGINT NOT NULL DEFAULT 1,
|
`XpPerMessage` BIGINT NOT NULL DEFAULT 1,
|
||||||
`XpPerReaction` BIGINT NOT NULL DEFAULT 1,
|
`XpPerReaction` BIGINT NOT NULL DEFAULT 1,
|
||||||
`MaxMessageXpPerHour` BIGINT NOT NULL DEFAULT 20,
|
`MaxMessageXpPerHour` BIGINT NOT NULL DEFAULT 20,
|
||||||
`XpPerOntimeHour` BIGINT NOT NULL DEFAULT 10,
|
`XpPerOntimeHour` BIGINT NOT NULL DEFAULT 10,
|
||||||
`XpPerEventParticipation` BIGINT NOT NULL DEFAULT 10,
|
`XpPerEventParticipation` BIGINT NOT NULL DEFAULT 10,
|
||||||
`XpPerAchievement` BIGINT NOT NULL DEFAULT 10,
|
`XpPerAchievement` BIGINT NOT NULL DEFAULT 10,
|
||||||
`AFKCommandChannelId` BIGINT NOT NULL,
|
`AFKCommandChannelId` BIGINT NOT NULL,
|
||||||
`HelpVoiceChannelId` BIGINT NOT NULL,
|
`HelpVoiceChannelId` BIGINT NOT NULL,
|
||||||
`TeamChannelId` BIGINT NOT NULL,
|
`TeamChannelId` BIGINT NOT NULL,
|
||||||
`LoginMessageChannelId` BIGINT NOT NULL,
|
`LoginMessageChannelId` BIGINT NOT NULL,
|
||||||
`ServerId` BIGINT NOT NULL,
|
`DefaultRoleId` BIGINT NULL,
|
||||||
`Deleted` BOOL DEFAULT FALSE,
|
`FeatureFlags` JSON NULL DEFAULT ('{}'),
|
||||||
`DateFrom` DATETIME(6) NOT NULL,
|
`ServerId` BIGINT NOT NULL,
|
||||||
`DateTo` DATETIME(6) NOT NULL
|
`Deleted` BOOL DEFAULT FALSE,
|
||||||
|
`DateFrom` DATETIME(6) NOT NULL,
|
||||||
|
`DateTo` DATETIME(6) NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
DROP TRIGGER IF EXISTS `TR_CFG_ServerUpdate`;
|
DROP TRIGGER IF EXISTS `TR_CFG_ServerUpdate`;
|
||||||
@ -27,44 +29,44 @@ CREATE TRIGGER `TR_CFG_ServerUpdate`
|
|||||||
ON `CFG_Server`
|
ON `CFG_Server`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO `CFG_ServerHistory` (
|
INSERT INTO `CFG_ServerHistory` (`Id`,
|
||||||
`Id`,
|
`MessageDeleteTimer`,
|
||||||
`MessageDeleteTimer`,
|
`NotificationChatId`,
|
||||||
`NotificationChatId`,
|
`MaxVoiceStateHours`,
|
||||||
`MaxVoiceStateHours`,
|
`XpPerMessage`,
|
||||||
`XpPerMessage`,
|
`XpPerReaction`,
|
||||||
`XpPerReaction`,
|
`MaxMessageXpPerHour`,
|
||||||
`MaxMessageXpPerHour`,
|
`XpPerOntimeHour`,
|
||||||
`XpPerOntimeHour`,
|
`XpPerEventParticipation`,
|
||||||
`XpPerEventParticipation`,
|
`XpPerAchievement`,
|
||||||
`XpPerAchievement`,
|
`AFKCommandChannelId`,
|
||||||
`AFKCommandChannelId`,
|
`HelpVoiceChannelId`,
|
||||||
`HelpVoiceChannelId`,
|
`TeamChannelId`,
|
||||||
`TeamChannelId`,
|
`LoginMessageChannelId`,
|
||||||
`LoginMessageChannelId`,
|
`DefaultRoleId`,
|
||||||
`ServerId`,
|
`FeatureFlags`,
|
||||||
`DateFrom`,
|
`ServerId`,
|
||||||
`DateTo`
|
`DateFrom`,
|
||||||
)
|
`DateTo`)
|
||||||
VALUES (
|
VALUES (OLD.Id,
|
||||||
OLD.Id,
|
OLD.MessageDeleteTimer,
|
||||||
OLD.MessageDeleteTimer,
|
OLD.NotificationChatId,
|
||||||
OLD.NotificationChatId,
|
OLD.MaxVoiceStateHours,
|
||||||
OLD.MaxVoiceStateHours,
|
OLD.XpPerMessage,
|
||||||
OLD.XpPerMessage,
|
OLD.XpPerReaction,
|
||||||
OLD.XpPerReaction,
|
OLD.MaxMessageXpPerHour,
|
||||||
OLD.MaxMessageXpPerHour,
|
OLD.XpPerOntimeHour,
|
||||||
OLD.XpPerOntimeHour,
|
OLD.XpPerEventParticipation,
|
||||||
OLD.XpPerEventParticipation,
|
OLD.XpPerAchievement,
|
||||||
OLD.XpPerAchievement,
|
OLD.AFKCommandChannelId,
|
||||||
OLD.AFKCommandChannelId,
|
OLD.HelpVoiceChannelId,
|
||||||
OLD.HelpVoiceChannelId,
|
OLD.TeamChannelId,
|
||||||
OLD.TeamChannelId,
|
OLD.LoginMessageChannelId,
|
||||||
OLD.LoginMessageChannelId,
|
OLD.DefaultRoleId,
|
||||||
OLD.ServerId,
|
OLD.FeatureFlags,
|
||||||
OLD.LastModifiedAt,
|
OLD.ServerId,
|
||||||
CURRENT_TIMESTAMP(6)
|
OLD.LastModifiedAt,
|
||||||
);
|
CURRENT_TIMESTAMP(6));
|
||||||
END;
|
END;
|
||||||
|
|
||||||
DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`;
|
DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`;
|
||||||
@ -74,44 +76,44 @@ CREATE TRIGGER `TR_CFG_ServerDelete`
|
|||||||
ON `CFG_Server`
|
ON `CFG_Server`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO `CFG_ServerHistory` (
|
INSERT INTO `CFG_ServerHistory` (`Id`,
|
||||||
`Id`,
|
`MessageDeleteTimer`,
|
||||||
`MessageDeleteTimer`,
|
`NotificationChatId`,
|
||||||
`NotificationChatId`,
|
`MaxVoiceStateHours`,
|
||||||
`MaxVoiceStateHours`,
|
`XpPerMessage`,
|
||||||
`XpPerMessage`,
|
`XpPerReaction`,
|
||||||
`XpPerReaction`,
|
`MaxMessageXpPerHour`,
|
||||||
`MaxMessageXpPerHour`,
|
`XpPerOntimeHour`,
|
||||||
`XpPerOntimeHour`,
|
`XpPerEventParticipation`,
|
||||||
`XpPerEventParticipation`,
|
`XpPerAchievement`,
|
||||||
`XpPerAchievement`,
|
`AFKCommandChannelId`,
|
||||||
`AFKCommandChannelId`,
|
`HelpVoiceChannelId`,
|
||||||
`HelpVoiceChannelId`,
|
`TeamChannelId`,
|
||||||
`TeamChannelId`,
|
`LoginMessageChannelId`,
|
||||||
`LoginMessageChannelId`,
|
`DefaultRoleId`,
|
||||||
`ServerId`,
|
`ServerId`,
|
||||||
`Deleted`,
|
`FeatureFlags`,
|
||||||
`DateFrom`,
|
`Deleted`,
|
||||||
`DateTo`
|
`DateFrom`,
|
||||||
)
|
`DateTo`)
|
||||||
VALUES (
|
VALUES (OLD.Id,
|
||||||
OLD.Id,
|
OLD.MessageDeleteTimer,
|
||||||
OLD.MessageDeleteTimer,
|
OLD.NotificationChatId,
|
||||||
OLD.NotificationChatId,
|
OLD.MaxVoiceStateHours,
|
||||||
OLD.MaxVoiceStateHours,
|
OLD.XpPerMessage,
|
||||||
OLD.XpPerMessage,
|
OLD.XpPerReaction,
|
||||||
OLD.XpPerReaction,
|
OLD.MaxMessageXpPerHour,
|
||||||
OLD.MaxMessageXpPerHour,
|
OLD.XpPerOntimeHour,
|
||||||
OLD.XpPerOntimeHour,
|
OLD.XpPerEventParticipation,
|
||||||
OLD.XpPerEventParticipation,
|
OLD.XpPerAchievement,
|
||||||
OLD.XpPerAchievement,
|
OLD.AFKCommandChannelId,
|
||||||
OLD.AFKCommandChannelId,
|
OLD.HelpVoiceChannelId,
|
||||||
OLD.HelpVoiceChannelId,
|
OLD.TeamChannelId,
|
||||||
OLD.TeamChannelId,
|
OLD.LoginMessageChannelId,
|
||||||
OLD.LoginMessageChannelId,
|
OLD.DefaultRoleId,
|
||||||
OLD.ServerId,
|
OLD.FeatureFlags,
|
||||||
TRUE,
|
OLD.ServerId,
|
||||||
OLD.LastModifiedAt,
|
TRUE,
|
||||||
CURRENT_TIMESTAMP(6)
|
OLD.LastModifiedAt,
|
||||||
);
|
CURRENT_TIMESTAMP(6));
|
||||||
END;
|
END;
|
@ -1,13 +1,14 @@
|
|||||||
CREATE TABLE IF NOT EXISTS `CFG_TechnicianHistory`
|
CREATE TABLE IF NOT EXISTS `CFG_TechnicianHistory`
|
||||||
(
|
(
|
||||||
`Id` BIGINT(20) NOT NULL,
|
`Id` BIGINT(20) NOT NULL,
|
||||||
`HelpCommandReferenceUrl` VARCHAR(255) NOT NULL,
|
`HelpCommandReferenceUrl` VARCHAR(255) NOT NULL,
|
||||||
`WaitForRestart` BIGINT NOT NULL DEFAULT 8,
|
`WaitForRestart` BIGINT NOT NULL DEFAULT 8,
|
||||||
`WaitForShutdown` BIGINT NOT NULL DEFAULT 8,
|
`WaitForShutdown` BIGINT NOT NULL DEFAULT 8,
|
||||||
`CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000,
|
`CacheMaxMessages` BIGINT NOT NULL DEFAULT 1000000,
|
||||||
`Deleted` BOOL DEFAULT FALSE,
|
`FeatureFlags` JSON NULL DEFAULT ('{}'),
|
||||||
`DateFrom` DATETIME(6) NOT NULL,
|
`Deleted` BOOL DEFAULT FALSE,
|
||||||
`DateTo` DATETIME(6) NOT NULL
|
`DateFrom` DATETIME(6) NOT NULL,
|
||||||
|
`DateTo` DATETIME(6) NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
DROP TRIGGER IF EXISTS `TR_CFG_TechnicianUpdate`;
|
DROP TRIGGER IF EXISTS `TR_CFG_TechnicianUpdate`;
|
||||||
@ -17,24 +18,22 @@ CREATE TRIGGER `TR_CFG_TechnicianUpdate`
|
|||||||
ON `CFG_Technician`
|
ON `CFG_Technician`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO `CFG_TechnicianHistory` (
|
INSERT INTO `CFG_TechnicianHistory` (`Id`,
|
||||||
`Id`,
|
`HelpCommandReferenceUrl`,
|
||||||
`HelpCommandReferenceUrl`,
|
`WaitForRestart`,
|
||||||
`WaitForRestart`,
|
`WaitForShutdown`,
|
||||||
`WaitForShutdown`,
|
`CacheMaxMessages`,
|
||||||
`CacheMaxMessages`,
|
`FeatureFlags`,
|
||||||
`DateFrom`,
|
`DateFrom`,
|
||||||
`DateTo`
|
`DateTo`)
|
||||||
)
|
VALUES (OLD.Id,
|
||||||
VALUES (
|
OLD.HelpCommandReferenceUrl,
|
||||||
OLD.Id,
|
OLD.WaitForRestart,
|
||||||
OLD.HelpCommandReferenceUrl,
|
OLD.WaitForShutdown,
|
||||||
OLD.WaitForRestart,
|
OLD.CacheMaxMessages,
|
||||||
OLD.WaitForShutdown,
|
OLD.FeatureFlags,
|
||||||
OLD.CacheMaxMessages,
|
OLD.LastModifiedAt,
|
||||||
OLD.LastModifiedAt,
|
CURRENT_TIMESTAMP(6));
|
||||||
CURRENT_TIMESTAMP(6)
|
|
||||||
);
|
|
||||||
END;
|
END;
|
||||||
|
|
||||||
DROP TRIGGER IF EXISTS `TR_CFG_TechnicianDelete`;
|
DROP TRIGGER IF EXISTS `TR_CFG_TechnicianDelete`;
|
||||||
@ -44,24 +43,22 @@ CREATE TRIGGER `TR_CFG_TechnicianDelete`
|
|||||||
ON `CFG_Technician`
|
ON `CFG_Technician`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO `CFG_TechnicianHistory` (
|
INSERT INTO `CFG_TechnicianHistory` (`Id`,
|
||||||
`Id`,
|
`HelpCommandReferenceUrl`,
|
||||||
`HelpCommandReferenceUrl`,
|
`WaitForRestart`,
|
||||||
`WaitForRestart`,
|
`WaitForShutdown`,
|
||||||
`WaitForShutdown`,
|
`CacheMaxMessages`,
|
||||||
`CacheMaxMessages`,
|
`FeatureFlags`,
|
||||||
`Deleted`,
|
`Deleted`,
|
||||||
`DateFrom`,
|
`DateFrom`,
|
||||||
`DateTo`
|
`DateTo`)
|
||||||
)
|
VALUES (OLD.Id,
|
||||||
VALUES (
|
OLD.HelpCommandReferenceUrl,
|
||||||
OLD.Id,
|
OLD.WaitForRestart,
|
||||||
OLD.HelpCommandReferenceUrl,
|
OLD.WaitForShutdown,
|
||||||
OLD.WaitForRestart,
|
OLD.CacheMaxMessages,
|
||||||
OLD.WaitForShutdown,
|
OLD.FeatureFlags,
|
||||||
OLD.CacheMaxMessages,
|
TRUE,
|
||||||
TRUE,
|
OLD.LastModifiedAt,
|
||||||
OLD.LastModifiedAt,
|
CURRENT_TIMESTAMP(6));
|
||||||
CURRENT_TIMESTAMP(6)
|
|
||||||
);
|
|
||||||
END;
|
END;
|
22
kdb-bot/src/bot_data/migration/fix_updates_migration.py
Normal file
22
kdb-bot/src/bot_data/migration/fix_updates_migration.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
from bot_data.abc.migration_abc import MigrationABC
|
||||||
|
from bot_data.db_context import DBContext
|
||||||
|
|
||||||
|
|
||||||
|
class FixUpdatesMigration(MigrationABC):
|
||||||
|
name = "1.1.7_FixUpdatesMigration"
|
||||||
|
|
||||||
|
def __init__(self, logger: DatabaseLogger, db: DBContext):
|
||||||
|
MigrationABC.__init__(self)
|
||||||
|
self._logger = logger
|
||||||
|
self._db = db
|
||||||
|
self._cursor = db.cursor
|
||||||
|
|
||||||
|
def upgrade(self):
|
||||||
|
self._logger.debug(__name__, "Running upgrade")
|
||||||
|
|
||||||
|
self._exec("config/server.sql")
|
||||||
|
self._exec("config/technician.sql")
|
||||||
|
|
||||||
|
def downgrade(self):
|
||||||
|
pass
|
@ -32,7 +32,7 @@ class ShortRoleNameMigration(MigrationABC):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self._exec("config/short_rule_names.sql")
|
self._exec("short_rule_names.sql")
|
||||||
|
|
||||||
def downgrade(self):
|
def downgrade(self):
|
||||||
self._cursor.execute("DROP TABLE `ShortRoleNames`;")
|
self._cursor.execute("DROP TABLE `ShortRoleNames`;")
|
||||||
|
Loading…
Reference in New Issue
Block a user