Management Commands¶
Note Commands are intended for maintainers. They read and write database state and should be run in controlled environments.
Wiki ingestion and rebuild¶
fetch_wiki_data¶
⚠️ Note
fetch_wiki_dataonly accepts truefandom.comhosts for the MediaWiki parse-API fallback. Crafted hosts that merely containfandom.comas a substring are rejected.
Fetch and version wiki-derived data.
This command fetches selected wiki pages and versions extracted table rows into
core.WikiData for later offline population steps.
Design goals:
- store whitespace-normalized raw strings only,
- version by deterministic content hashes (no overwrites),
- support safe dry-run mode via --check,
- keep parsing strict but resilient to wiki layout changes.
Command
¶
Bases: BaseCommand
Fetch a single wiki table and store versioned rows.
This command intentionally does not feed wiki data into analysis or charts. It exists only to capture stable, attributable inputs for later phases.
rebuild_wiki_definitions¶
Rebuild wiki-derived definition tables (Definitions layer).
This command orchestrates:
1) wiki ingestion into definitions.WikiData (optional, online), then
2) offline translation into structured definition + parameter tables.
It must not delete Player State or GameData rows.
purge_wiki_definitions¶
Purge structured wiki-derived Definitions (Definitions layer).
This command deletes only: - definition rows (bots/UWs/guardians/cards), - parameter definition rows, - parameter level rows.
It does not delete definitions.WikiData and does not touch Player State or
GameData tables (though FK relationships may be nulled via SET_NULL).
sync_player_state¶
⚠️ Note
sync_player_state --playerrefers to a username (the owning account), not a standalone Player name. The command requires either--playeror--allplus an explicit--checkor--write.
Battle report maintenance¶
reparse_battle_reports¶
Reparse is idempotent and supports scoped backfills.
--limitprocesses the most recent N reports (highest ids) after any other filters.--patchlimits processing to the patch window that starts at the selected PatchBoundary date and ends at the next boundary date (exclusive). Provide a boundary label or ISO date.- Reparse also backfills bot usage rows used by Runs used on the Bots dashboard.
Deployment helpers¶
deploy_railway¶
Runs the deploy-time pipeline (migrations, wiki rebuild, reparse).
- Requires
--writeto run. --skip-migrationsskipsmigrate.--skip-wikiskipsrebuild_wiki_definitions --target all --write.--skip-reparseskipsreparse_battle_reports --write.TOWERSTATS_WIKI_OFFLINE=1forcesrebuild_wiki_definitions --skip-fetch(no network fetch).TOWERSTATS_WIKI_REBUILD_TIMEOUT_SECONDScaps wiki rebuild runtime (default 300 seconds, set to 0 to disable). When exceeded, the rebuild is skipped and deploy continues.- Wiki rebuild failures are logged and do not abort the deploy pipeline.