Core/Players: Store player creation timestamp and type (normal/npe)

Port From (https://github.com/TrinityCore/TrinityCore/commit/11762273c68b24b332238aa89a73b9ed9ac1d249)
This commit is contained in:
hondacrx
2021-10-02 20:50:59 -04:00
parent 9785c8cb0e
commit 4a97883559
7 changed files with 36 additions and 4 deletions
@@ -0,0 +1,12 @@
ALTER TABLE `characters`
ADD `createTime` bigint(20) NOT NULL DEFAULT '0' AFTER `online`,
ADD `createMode` tinyint(4) NOT NULL DEFAULT '0' AFTER `createTime`;
-- AT_LOGIN_FIRST: Characters that have never logged in have accurate creation timestamp in `logout_time`
UPDATE `characters` SET `createTime`=`logout_time` WHERE (`at_login` & 0x20) != 0;
-- attempt to find lowest criteria timestamp for characters that have logged in already
UPDATE `characters` SET `createTime`=(SELECT COALESCE(MIN(candidates.`date`), UNIX_TIMESTAMP()) FROM (
SELECT MIN(cap.`date`) `date` FROM `character_achievement_progress` cap WHERE cap.`guid`=`characters`.`guid`
UNION
SELECT MIN(ca.`date`) `date` FROM `character_achievement` ca WHERE ca.`guid`=`characters`.`guid`
) candidates) WHERE (`at_login` & 0x20) = 0;