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()
|
||||||
|
@ -14,6 +14,8 @@ CREATE TABLE IF NOT EXISTS `CFG_ServerHistory`
|
|||||||
`HelpVoiceChannelId` BIGINT NOT NULL,
|
`HelpVoiceChannelId` BIGINT NOT NULL,
|
||||||
`TeamChannelId` BIGINT NOT NULL,
|
`TeamChannelId` BIGINT NOT NULL,
|
||||||
`LoginMessageChannelId` BIGINT NOT NULL,
|
`LoginMessageChannelId` BIGINT NOT NULL,
|
||||||
|
`DefaultRoleId` BIGINT NULL,
|
||||||
|
`FeatureFlags` JSON NULL DEFAULT ('{}'),
|
||||||
`ServerId` BIGINT NOT NULL,
|
`ServerId` BIGINT NOT NULL,
|
||||||
`Deleted` BOOL DEFAULT FALSE,
|
`Deleted` BOOL DEFAULT FALSE,
|
||||||
`DateFrom` DATETIME(6) NOT NULL,
|
`DateFrom` DATETIME(6) NOT NULL,
|
||||||
@ -27,8 +29,7 @@ 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`,
|
||||||
@ -42,12 +43,12 @@ BEGIN
|
|||||||
`HelpVoiceChannelId`,
|
`HelpVoiceChannelId`,
|
||||||
`TeamChannelId`,
|
`TeamChannelId`,
|
||||||
`LoginMessageChannelId`,
|
`LoginMessageChannelId`,
|
||||||
|
`DefaultRoleId`,
|
||||||
|
`FeatureFlags`,
|
||||||
`ServerId`,
|
`ServerId`,
|
||||||
`DateFrom`,
|
`DateFrom`,
|
||||||
`DateTo`
|
`DateTo`)
|
||||||
)
|
VALUES (OLD.Id,
|
||||||
VALUES (
|
|
||||||
OLD.Id,
|
|
||||||
OLD.MessageDeleteTimer,
|
OLD.MessageDeleteTimer,
|
||||||
OLD.NotificationChatId,
|
OLD.NotificationChatId,
|
||||||
OLD.MaxVoiceStateHours,
|
OLD.MaxVoiceStateHours,
|
||||||
@ -61,10 +62,11 @@ BEGIN
|
|||||||
OLD.HelpVoiceChannelId,
|
OLD.HelpVoiceChannelId,
|
||||||
OLD.TeamChannelId,
|
OLD.TeamChannelId,
|
||||||
OLD.LoginMessageChannelId,
|
OLD.LoginMessageChannelId,
|
||||||
|
OLD.DefaultRoleId,
|
||||||
|
OLD.FeatureFlags,
|
||||||
OLD.ServerId,
|
OLD.ServerId,
|
||||||
OLD.LastModifiedAt,
|
OLD.LastModifiedAt,
|
||||||
CURRENT_TIMESTAMP(6)
|
CURRENT_TIMESTAMP(6));
|
||||||
);
|
|
||||||
END;
|
END;
|
||||||
|
|
||||||
DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`;
|
DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`;
|
||||||
@ -74,8 +76,7 @@ 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`,
|
||||||
@ -89,13 +90,13 @@ BEGIN
|
|||||||
`HelpVoiceChannelId`,
|
`HelpVoiceChannelId`,
|
||||||
`TeamChannelId`,
|
`TeamChannelId`,
|
||||||
`LoginMessageChannelId`,
|
`LoginMessageChannelId`,
|
||||||
|
`DefaultRoleId`,
|
||||||
`ServerId`,
|
`ServerId`,
|
||||||
|
`FeatureFlags`,
|
||||||
`Deleted`,
|
`Deleted`,
|
||||||
`DateFrom`,
|
`DateFrom`,
|
||||||
`DateTo`
|
`DateTo`)
|
||||||
)
|
VALUES (OLD.Id,
|
||||||
VALUES (
|
|
||||||
OLD.Id,
|
|
||||||
OLD.MessageDeleteTimer,
|
OLD.MessageDeleteTimer,
|
||||||
OLD.NotificationChatId,
|
OLD.NotificationChatId,
|
||||||
OLD.MaxVoiceStateHours,
|
OLD.MaxVoiceStateHours,
|
||||||
@ -109,9 +110,10 @@ BEGIN
|
|||||||
OLD.HelpVoiceChannelId,
|
OLD.HelpVoiceChannelId,
|
||||||
OLD.TeamChannelId,
|
OLD.TeamChannelId,
|
||||||
OLD.LoginMessageChannelId,
|
OLD.LoginMessageChannelId,
|
||||||
|
OLD.DefaultRoleId,
|
||||||
|
OLD.FeatureFlags,
|
||||||
OLD.ServerId,
|
OLD.ServerId,
|
||||||
TRUE,
|
TRUE,
|
||||||
OLD.LastModifiedAt,
|
OLD.LastModifiedAt,
|
||||||
CURRENT_TIMESTAMP(6)
|
CURRENT_TIMESTAMP(6));
|
||||||
);
|
|
||||||
END;
|
END;
|
@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS `CFG_TechnicianHistory`
|
|||||||
`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,
|
||||||
|
`FeatureFlags` JSON NULL DEFAULT ('{}'),
|
||||||
`Deleted` BOOL DEFAULT FALSE,
|
`Deleted` BOOL DEFAULT FALSE,
|
||||||
`DateFrom` DATETIME(6) NOT NULL,
|
`DateFrom` DATETIME(6) NOT NULL,
|
||||||
`DateTo` DATETIME(6) NOT NULL
|
`DateTo` DATETIME(6) NOT NULL
|
||||||
@ -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.Id,
|
|
||||||
OLD.HelpCommandReferenceUrl,
|
OLD.HelpCommandReferenceUrl,
|
||||||
OLD.WaitForRestart,
|
OLD.WaitForRestart,
|
||||||
OLD.WaitForShutdown,
|
OLD.WaitForShutdown,
|
||||||
OLD.CacheMaxMessages,
|
OLD.CacheMaxMessages,
|
||||||
|
OLD.FeatureFlags,
|
||||||
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.Id,
|
|
||||||
OLD.HelpCommandReferenceUrl,
|
OLD.HelpCommandReferenceUrl,
|
||||||
OLD.WaitForRestart,
|
OLD.WaitForRestart,
|
||||||
OLD.WaitForShutdown,
|
OLD.WaitForShutdown,
|
||||||
OLD.CacheMaxMessages,
|
OLD.CacheMaxMessages,
|
||||||
|
OLD.FeatureFlags,
|
||||||
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