Added maintenance to db and gql #424

This commit is contained in:
2023-11-06 18:02:04 +01:00
parent a7c833b9db
commit e1258151de
13 changed files with 89 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS `CFG_TechnicianHistory`
`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,
@@ -25,6 +26,7 @@ BEGIN
`WaitForShutdown`,
`CacheMaxMessages`,
`MaxSteamOfferCount`,
`Maintenance`,
`FeatureFlags`,
`DateFrom`,
`DateTo`)
@@ -34,6 +36,7 @@ BEGIN
OLD.WaitForShutdown,
OLD.CacheMaxMessages,
OLD.MaxSteamOfferCount,
OLD.Maintenance,
OLD.FeatureFlags,
OLD.LastModifiedAt,
CURRENT_TIMESTAMP(6));
@@ -52,6 +55,7 @@ BEGIN
`WaitForShutdown`,
`CacheMaxMessages`,
`MaxSteamOfferCount`,
`Maintenance`,
`FeatureFlags`,
`Deleted`,
`DateFrom`,
@@ -62,6 +66,7 @@ BEGIN
OLD.WaitForShutdown,
OLD.CacheMaxMessages,
OLD.MaxSteamOfferCount,
OLD.Maintenance,
OLD.FeatureFlags,
TRUE,
OLD.LastModifiedAt,

View File

@@ -0,0 +1,51 @@
from bot_core.logging.database_logger import DatabaseLogger
from bot_data.abc.migration_abc import MigrationABC
from bot_data.db_context import DBContext
class MaintenanceModeMigration(MigrationABC):
name = "1.2.0_MaintenanceModeMigration"
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"""
ALTER TABLE CFG_Technician
ADD Maintenance BOOLEAN DEFAULT FALSE AFTER MaxSteamOfferCount;
"""
)
)
self._cursor.execute(
str(
f"""
ALTER TABLE CFG_TechnicianHistory
ADD Maintenance BOOLEAN DEFAULT FALSE AFTER MaxSteamOfferCount;
"""
)
)
self._exec(__file__, "config/technician.sql")
def downgrade(self):
self._cursor.execute(
str(
f"""
ALTER TABLE CFG_Technician DROP COLUMN Maintenance;
"""
)
)
self._cursor.execute(
str(
f"""
ALTER TABLE CFG_TechnicianHistory DROP COLUMN Maintenance;
"""
)
)

View File

@@ -16,6 +16,7 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
wait_for_shutdown: int,
cache_max_messages: int,
max_steam_offer_count: int,
maintenance: bool,
feature_flags: dict[FeatureFlagsEnum],
technician_ids: List[int],
ping_urls: List[str],
@@ -29,6 +30,8 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
self._wait_for_shutdown = wait_for_shutdown
self._cache_max_messages = cache_max_messages
self._max_steam_offer_count = max_steam_offer_count
self._maintenance = maintenance
self._feature_flags = feature_flags
self._technician_ids = technician_ids
self._ping_urls = ping_urls
@@ -105,6 +108,14 @@ class TechnicianConfig(TableABC, ConfigurationModelABC):
def ping_urls(self, value: List[str]):
self._ping_urls = value
@property
def maintenance(self) -> bool:
return self._maintenance
@maintenance.setter
def maintenance(self, value: bool):
self._maintenance = value
@staticmethod
def get_select_all_string() -> str:
return str(