Added migration for config in wi #127
This commit is contained in:
parent
bff435d51e
commit
ed9a55390c
55
kdb-bot/.cpl/schematic_migration.py
Normal file
55
kdb-bot/.cpl/schematic_migration.py
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(GenerateSchematicABC):
|
||||||
|
def __init__(self, *args: str):
|
||||||
|
GenerateSchematicABC.__init__(self, *args)
|
||||||
|
|
||||||
|
def get_code(self) -> str:
|
||||||
|
import textwrap
|
||||||
|
|
||||||
|
code = textwrap.dedent(
|
||||||
|
"""\
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
from bot_data.abc.migration_abc import MigrationABC
|
||||||
|
from bot_data.db_context import DBContext
|
||||||
|
|
||||||
|
|
||||||
|
class $ClassName(MigrationABC):
|
||||||
|
name = "1.0_$ClassName"
|
||||||
|
|
||||||
|
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._cursor.execute(
|
||||||
|
str(
|
||||||
|
f\"""
|
||||||
|
CREATE TABLE IF NOT EXISTS `$TableName` (
|
||||||
|
`Id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||||
|
`CreatedAt` DATETIME(6),
|
||||||
|
`LastModifiedAt` DATETIME(6),
|
||||||
|
PRIMARY KEY(`Id`)
|
||||||
|
);
|
||||||
|
\"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def downgrade(self):
|
||||||
|
self._cursor.execute("DROP TABLE `$TableName`;")
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
return self.build_code_str(
|
||||||
|
code,
|
||||||
|
ClassName=self._class_name,
|
||||||
|
TableName=self._class_name.split("Migration")[0],
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def register(cls):
|
||||||
|
GenerateSchematicABC.register(cls, "migration", [])
|
@ -1,7 +1,7 @@
|
|||||||
from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC
|
from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC
|
||||||
|
|
||||||
|
|
||||||
class query(GenerateSchematicABC):
|
class Query(GenerateSchematicABC):
|
||||||
def __init__(self, *args: str):
|
def __init__(self, *args: str):
|
||||||
GenerateSchematicABC.__init__(self, *args)
|
GenerateSchematicABC.__init__(self, *args)
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ from bot_data.migration.api_key_migration import ApiKeyMigration
|
|||||||
from bot_data.migration.api_migration import ApiMigration
|
from bot_data.migration.api_migration import ApiMigration
|
||||||
from bot_data.migration.auto_role_fix1_migration import AutoRoleFix1Migration
|
from bot_data.migration.auto_role_fix1_migration import AutoRoleFix1Migration
|
||||||
from bot_data.migration.auto_role_migration import AutoRoleMigration
|
from bot_data.migration.auto_role_migration import AutoRoleMigration
|
||||||
|
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.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
|
||||||
@ -44,3 +45,4 @@ class StartupMigrationExtension(StartupExtensionABC):
|
|||||||
services.add_transient(MigrationABC, UserWarningMigration) # 21.02.2023 #35 - 1.0.0
|
services.add_transient(MigrationABC, UserWarningMigration) # 21.02.2023 #35 - 1.0.0
|
||||||
services.add_transient(MigrationABC, DBHistoryMigration) # 06.03.2023 #246 - 1.0.0
|
services.add_transient(MigrationABC, DBHistoryMigration) # 06.03.2023 #246 - 1.0.0
|
||||||
services.add_transient(MigrationABC, AchievementsMigration) # 14.06.2023 #268 - 1.1.0
|
services.add_transient(MigrationABC, AchievementsMigration) # 14.06.2023 #268 - 1.1.0
|
||||||
|
services.add_transient(MigrationABC, ConfigMigration) # 19.07.2023 #127 - 1.1.0
|
||||||
|
@ -20,3 +20,4 @@ class FeatureFlagsEnum(Enum):
|
|||||||
api_only = "ApiOnly"
|
api_only = "ApiOnly"
|
||||||
presence = "Presence"
|
presence = "Presence"
|
||||||
version_in_presence = "VersionInPresence"
|
version_in_presence = "VersionInPresence"
|
||||||
|
config_in_wi = "ConfigInWI"
|
||||||
|
@ -28,6 +28,7 @@ class FeatureFlagsSettings(ConfigurationModelABC):
|
|||||||
FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70
|
FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70
|
||||||
FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56
|
FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56
|
||||||
FeatureFlagsEnum.version_in_presence.value: False, # 21.03.2023 #253
|
FeatureFlagsEnum.version_in_presence.value: False, # 21.03.2023 #253
|
||||||
|
FeatureFlagsEnum.config_in_wi.value: True, # 19.07.2023 #127
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_flag(self, key: FeatureFlagsEnum) -> bool:
|
def get_flag(self, key: FeatureFlagsEnum) -> bool:
|
||||||
|
33
kdb-bot/src/bot_data/migration/config_migration.py
Normal file
33
kdb-bot/src/bot_data/migration/config_migration.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
from bot_data.abc.migration_abc import MigrationABC
|
||||||
|
from bot_data.db_context import DBContext
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigMigration(MigrationABC):
|
||||||
|
name = "1.1.0_ConfigMigration"
|
||||||
|
|
||||||
|
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._cursor.execute(
|
||||||
|
# str(
|
||||||
|
# f"""
|
||||||
|
# CREATE TABLE IF NOT EXISTS `Config` (
|
||||||
|
# `Id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||||
|
# `CreatedAt` DATETIME(6),
|
||||||
|
# `LastModifiedAt` DATETIME(6),
|
||||||
|
# PRIMARY KEY(`Id`)
|
||||||
|
# );
|
||||||
|
# """
|
||||||
|
# )
|
||||||
|
# )
|
||||||
|
|
||||||
|
def downgrade(self):
|
||||||
|
self._logger.debug(__name__, "Running downgrade")
|
||||||
|
# self._cursor.execute("DROP TABLE `Config`;")
|
Loading…
Reference in New Issue
Block a user