Add optional name history migration for sa_players_ips
SimpleAdmin upserts sa_players_ips on (steamid, address), so a rename on the same IP overwrites the old name. sql/players-ips-name-history.sql adds name to the primary key (binary collation, NOT NULL), so every name a SteamID joins with is kept and shows on its player page and in name search. SimpleAdmin's IP cache keeps only the newest row per IP, so its multi-account and IP-ban checks are unchanged. The file includes a revert.
This commit is contained in:
parent
b579941964
commit
657ead4c5a
2 changed files with 38 additions and 0 deletions
30
sql/players-ips-name-history.sql
Normal file
30
sql/players-ips-name-history.sql
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
-- Keep every name a SteamID has used, instead of overwriting it.
|
||||
--
|
||||
-- CS2-SimpleAdmin records each connect with an upsert keyed on sa_players_ips' primary key,
|
||||
-- (steamid, address), so a player who rejoins from the same IP under a new name overwrites the old
|
||||
-- name. With name in the key, a new name on the same SteamID+IP is a new row; the same name again
|
||||
-- still just bumps used_at. SimpleAdmin's own code is unchanged: its IP cache already keeps only
|
||||
-- the newest row per IP, so multi-account and IP-ban checks behave as before.
|
||||
--
|
||||
-- name becomes binary-collated so a case-only rename ("astra" -> "Astra") is also kept, and NOT
|
||||
-- NULL because primary key columns can't be NULL (SimpleAdmin always writes a name).
|
||||
--
|
||||
-- Only records names at connect, like before: a rename mid-session shows up on the next join.
|
||||
-- Re-check after upgrading SimpleAdmin, in case a later migration rebuilds this table's key.
|
||||
|
||||
UPDATE sa_players_ips SET name = '' WHERE name IS NULL;
|
||||
|
||||
ALTER TABLE sa_players_ips
|
||||
MODIFY name VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (steamid, address, name);
|
||||
|
||||
-- Revert (drops the older names, keeping the newest row per SteamID+IP):
|
||||
--
|
||||
-- DELETE a FROM sa_players_ips a JOIN sa_players_ips b
|
||||
-- ON a.steamid = b.steamid AND a.address = b.address
|
||||
-- AND (a.used_at < b.used_at OR (a.used_at = b.used_at AND a.name < b.name));
|
||||
-- ALTER TABLE sa_players_ips
|
||||
-- DROP PRIMARY KEY,
|
||||
-- ADD PRIMARY KEY (steamid, address),
|
||||
-- MODIFY name VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL;
|
||||
Loading…
Add table
Add a link
Reference in a new issue