Added setting to server config #391
This commit is contained in:
parent
2f10ace27f
commit
d91c76467d
@ -18,6 +18,7 @@ from bot_data.migration.initial_migration import InitialMigration
|
||||
from bot_data.migration.level_migration import LevelMigration
|
||||
from bot_data.migration.remove_stats_migration import RemoveStatsMigration
|
||||
from bot_data.migration.short_role_name_migration import ShortRoleNameMigration
|
||||
from bot_data.migration.short_role_name_only_highest_migration import ShortRoleNameOnlyHighestMigration
|
||||
from bot_data.migration.stats_migration import StatsMigration
|
||||
from bot_data.migration.user_joined_game_server_migration import UserJoinedGameServerMigration
|
||||
from bot_data.migration.user_message_count_per_hour_migration import (
|
||||
@ -54,3 +55,4 @@ class StartupMigrationExtension(StartupExtensionABC):
|
||||
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, FixUpdatesMigration) # 28.09.2023 #378 - 1.1.7
|
||||
services.add_transient(MigrationABC, ShortRoleNameOnlyHighestMigration) # 02.10.2023 #391 - 1.1.9
|
||||
|
@ -1,25 +1,26 @@
|
||||
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,
|
||||
`FeatureFlags` JSON NULL DEFAULT ('{}'),
|
||||
`ServerId` BIGINT NOT NULL,
|
||||
`Deleted` BOOL DEFAULT FALSE,
|
||||
`DateFrom` DATETIME(6) NOT NULL,
|
||||
`DateTo` DATETIME(6) NOT NULL
|
||||
`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`;
|
||||
@ -44,6 +45,7 @@ BEGIN
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`DefaultRoleId`,
|
||||
`ShortRoleNameSetOnlyHighest`,
|
||||
`FeatureFlags`,
|
||||
`ServerId`,
|
||||
`DateFrom`,
|
||||
@ -63,6 +65,7 @@ BEGIN
|
||||
OLD.TeamChannelId,
|
||||
OLD.LoginMessageChannelId,
|
||||
OLD.DefaultRoleId,
|
||||
OLD.ShortRoleNameSetOnlyHighest,
|
||||
OLD.FeatureFlags,
|
||||
OLD.ServerId,
|
||||
OLD.LastModifiedAt,
|
||||
@ -91,6 +94,7 @@ BEGIN
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`DefaultRoleId`,
|
||||
`ShortRoleNameSetOnlyHighest`,
|
||||
`ServerId`,
|
||||
`FeatureFlags`,
|
||||
`Deleted`,
|
||||
@ -111,6 +115,7 @@ BEGIN
|
||||
OLD.TeamChannelId,
|
||||
OLD.LoginMessageChannelId,
|
||||
OLD.DefaultRoleId,
|
||||
OLD.ShortRoleNameSetOnlyHighest,
|
||||
OLD.FeatureFlags,
|
||||
OLD.ServerId,
|
||||
TRUE,
|
||||
|
@ -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 ShortRoleNameOnlyHighestMigration(MigrationABC):
|
||||
name = "1.1.9_ShortRoleNameOnlyHighestMigration"
|
||||
|
||||
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_Server
|
||||
ADD ShortRoleNameSetOnlyHighest BOOLEAN NOT NULL DEFAULT FALSE AFTER DefaultRoleId;
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_ServerHistory
|
||||
ADD ShortRoleNameSetOnlyHighest BOOLEAN NOT NULL DEFAULT FALSE AFTER DefaultRoleId;
|
||||
"""
|
||||
)
|
||||
)
|
||||
self._exec(__file__, "config/server.sql")
|
||||
|
||||
def downgrade(self):
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_Server DROP COLUMN ShortRoleNameSetOnlyHighest;
|
||||
"""
|
||||
)
|
||||
)
|
||||
self._cursor.execute(
|
||||
str(
|
||||
f"""
|
||||
ALTER TABLE CFG_ServerHistory DROP COLUMN ShortRoleNameSetOnlyHighest;
|
||||
"""
|
||||
)
|
||||
)
|
@ -29,6 +29,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
team_channel_id: int,
|
||||
login_message_channel_id: int,
|
||||
default_role_id: Optional[int],
|
||||
short_role_name_only_set_highest_role: bool,
|
||||
feature_flags: dict[FeatureFlagsEnum],
|
||||
server: Server,
|
||||
afk_channel_ids: List[int],
|
||||
@ -52,6 +53,8 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
self._team_channel_id = team_channel_id
|
||||
self._login_message_channel_id = login_message_channel_id
|
||||
self._default_role_id = default_role_id
|
||||
self._short_role_name_only_set_highest_role = short_role_name_only_set_highest_role
|
||||
|
||||
self._feature_flags = feature_flags
|
||||
self._server = server
|
||||
self._afk_channel_ids = afk_channel_ids
|
||||
@ -78,6 +81,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
guild.system_channel.id,
|
||||
guild.system_channel.id,
|
||||
None,
|
||||
False,
|
||||
{},
|
||||
server,
|
||||
List(int),
|
||||
@ -200,6 +204,14 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
def default_role_id(self, value: int):
|
||||
self._default_role_id = value
|
||||
|
||||
@property
|
||||
def short_role_name_only_set_highest_role(self) -> bool:
|
||||
return self._short_role_name_only_set_highest_role
|
||||
|
||||
@short_role_name_only_set_highest_role.setter
|
||||
def short_role_name_only_set_highest_role(self, value: bool):
|
||||
self._short_role_name_only_set_highest_role = value
|
||||
|
||||
@property
|
||||
def feature_flags(self) -> dict[FeatureFlagsEnum]:
|
||||
return self._feature_flags
|
||||
|
@ -18,6 +18,7 @@ class ServerConfigHistory(HistoryTableABC):
|
||||
team_channel_id: int,
|
||||
login_message_channel_id: int,
|
||||
default_role_id: int,
|
||||
short_role_name_only_set_highest_role: bool,
|
||||
feature_flags: dict[str],
|
||||
server_id: int,
|
||||
deleted: bool,
|
||||
@ -42,6 +43,8 @@ class ServerConfigHistory(HistoryTableABC):
|
||||
self._team_channel_id = team_channel_id
|
||||
self._login_message_channel_id = login_message_channel_id
|
||||
self._default_role_id = default_role_id
|
||||
self._short_role_name_only_set_highest_role = short_role_name_only_set_highest_role
|
||||
|
||||
self._feature_flags = feature_flags
|
||||
self._server_id = server_id
|
||||
|
||||
@ -105,6 +108,10 @@ class ServerConfigHistory(HistoryTableABC):
|
||||
def default_role_id(self) -> int:
|
||||
return self._default_role_id
|
||||
|
||||
@property
|
||||
def short_role_name_only_set_highest_role(self) -> bool:
|
||||
return self._short_role_name_only_set_highest_role
|
||||
|
||||
@property
|
||||
def feature_flags(self) -> dict[str]:
|
||||
return self._feature_flags
|
||||
|
@ -65,12 +65,13 @@ class ServerConfigRepositoryService(ServerConfigRepositoryABC):
|
||||
result[12],
|
||||
result[13],
|
||||
result[14],
|
||||
json.loads(result[15]),
|
||||
self._servers.get_server_by_id(result[16]),
|
||||
self._get_afk_channel_ids(result[16]),
|
||||
self._get_team_role_ids(result[16]),
|
||||
result[17],
|
||||
result[15],
|
||||
json.loads(result[16]),
|
||||
self._servers.get_server_by_id(result[17]),
|
||||
self._get_afk_channel_ids(result[17]),
|
||||
self._get_team_role_ids(result[17]),
|
||||
result[18],
|
||||
result[19],
|
||||
id=result[0],
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user