Repository navigation
v1.0.4
Trying to fix the database issue with duplicating fields https://github.com/KitsuneLab-Development/K4-RPG/issues/7
1.0.3 -> 1.0.4 Existing database migration steps
Step 1: Remove Duplicate Entries (Keep Highest Level)
-- Delete entries where a higher-level duplicate exists
DELETE ps1
FROM `k4-rpg_playerskills` ps1
INNER JOIN `k4-rpg_playerskills` ps2
ON
ps1.PlayerSteamID = ps2.PlayerSteamID AND
ps1.SkillID = ps2.SkillID AND
ps1.Level < ps2.Level;
Step 2: Remove Remaining Duplicates (Same Level)
-- Use a temporary table to deduplicate identical entries
CREATE TEMPORARY TABLE `temp_skills` AS
SELECT
PlayerSteamID,
SkillID,
MAX(Level) AS Level
FROM `k4-rpg_playerskills`
GROUP BY PlayerSteamID, SkillID;
-- Clear original table
TRUNCATE `k4-rpg_playerskills`;
-- Restore deduplicated data
INSERT INTO `k4-rpg_playerskills` (PlayerSteamID, SkillID, Level)
SELECT PlayerSteamID, SkillID, Level FROM `temp_skills`;
Step 3: Add Composite Primary Key
ALTER TABLE `k4-rpg_playerskills`
ADD PRIMARY KEY (PlayerSteamID, SkillID);
Full Changelog: v1.0.3...v1.0.4