Skip to content

Commit

Permalink
Convert old styler player IDs on startup (for U15.2) (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
cemathey authored Aug 27, 2024
1 parent 7f1de01 commit 5815cdc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ env
if [ "$1" == 'maintenance' ]
then
alembic upgrade head
# Convert old stye player IDs to new style (md5 hash)
# TODO: we can eventually remove this in a few releases once old installs have updated their game servers and CRCON
# SERVER_NUMBER is mandatory and not otherwise set in the maintenance container; only want it to run once
# LOGGING_PATH and LOGGING_FILENAME need to be passed to get it to log to the directory that is bind mounted
SERVER_NUMBER=1 LOGGING_PATH=/logs/ LOGGING_FILENAME=startup.log python -m rcon.cli convert_win_player_ids
cd rconweb
./manage.py makemigrations --no-input
./manage.py migrate --noinput
Expand Down
16 changes: 16 additions & 0 deletions rcon/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
BaseUserConfig,
BaseWebhookUserConfig,
)
from rcon.models import PlayerID, enter_session
from sqlalchemy import update
from sqlalchemy import func as pg_func
from rcon.utils import ApiKey

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -421,6 +424,19 @@ def reset_user_settings(server: int):
print("Done")


@cli.command(name="convert_win_player_ids")
def convert_win_player_ids():
with enter_session() as session:
logger.info(f"Converting old style windows store player IDs to new style")
stmt = (
update(PlayerID)
.filter(PlayerID.player_id.like("%-%"))
.values(player_id=pg_func.md5(PlayerID.player_id))
)
result = session.execute(stmt)
logger.info(f"Converted {result.rowcount} player IDs")


PREFIXES_TO_EXPOSE = ["get_", "set_", "do_"]
EXCLUDED: Set[str] = {"set_maprotation", "connection_pool"}

Expand Down

0 comments on commit 5815cdc

Please sign in to comment.