Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) SQL migration improvements #1225

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

enum
{
Migration_RemoveWorkshopMaptiers, // 0
Migration_RemoveWorkshopMapzones,
Migration_RemoveWorkshopPlayertimes,
Migration_LastLoginIndex,
Migration_RemoveCountry,
Migration_ConvertIPAddresses, // 5
Migration_RemoveWorkshopMaptiers, // 0 // safe with newly-created tables
Migration_RemoveWorkshopMapzones, // safe with newly-created tables
Migration_RemoveWorkshopPlayertimes, // safe with newly-created tables
Migration_LastLoginIndex, // safe with newly-created tables
Migration_RemoveCountry, // safe with newly-created tables -- doesn't work on sqlite
Migration_ConvertIPAddresses, // 5 //
Migration_ConvertSteamIDsUsers,
Migration_ConvertSteamIDsPlayertimes,
Migration_ConvertSteamIDsChat,
Expand Down Expand Up @@ -374,8 +374,11 @@ void ApplyMigration(int migration)

void ApplyMigration_LastLoginIndex()
{
char sQuery[128];
FormatEx(sQuery, 128, "ALTER TABLE `%susers` ADD INDEX `lastlogin` (`lastlogin`);", gS_SQLPrefix);
char sQuery[512];
if (gI_Driver == Driver_sqlite)
FormatEx(sQuery, 512, "CREATE INDEX IF NOT EXISTS lastlogin ON `%susers` (lastlogin);", gS_SQLPrefix);
else
FormatEx(sQuery, 512, "ALTER TABLE `%susers` ADD INDEX `lastlogin` (`lastlogin`);", gS_SQLPrefix);
QueryLog(gH_SQL, SQL_TableMigrationSingleQuery_Callback, sQuery, Migration_LastLoginIndex, DBPrio_High);
}

Expand Down
Loading