mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-08 02:48:26 +00:00
Add missing users to users table
This commit is contained in:
parent
de9cbc8470
commit
9ef34bce59
@ -619,9 +619,10 @@ public void SQL_TableMigrationPlayertimesAuthFK_Callback(Database db, DBResultSe
|
||||
Transaction trans = new Transaction();
|
||||
char sQuery[512];
|
||||
|
||||
results.FetchRow();
|
||||
|
||||
if (gI_Driver == Driver_mysql)
|
||||
{
|
||||
results.FetchRow();
|
||||
if (results.FetchInt(0)) // pt_auth CONSTRAINT exists
|
||||
{
|
||||
// Remove in case it has CASCADE referential actions (<= v3.0.8)
|
||||
@ -629,13 +630,18 @@ public void SQL_TableMigrationPlayertimesAuthFK_Callback(Database db, DBResultSe
|
||||
AddQueryLog(trans, sQuery);
|
||||
}
|
||||
|
||||
// add missing users to users table
|
||||
FormatEx(sQuery, sizeof(sQuery),
|
||||
"INSERT INTO `%susers` (auth) SELECT p1.auth FROM `%splayertimes` p1 LEFT JOIN `%susers` u1 ON u1.auth = p1.auth WHERE u1.auth IS NULL;",
|
||||
gS_SQLPrefix, gS_SQLPrefix, gS_SQLPrefix
|
||||
);
|
||||
AddQueryLog(trans, sQuery);
|
||||
|
||||
FormatEx(sQuery, sizeof(sQuery), "ALTER TABLE `%splayertimes` ADD CONSTRAINT `%spt_auth` FOREIGN KEY (`auth`) REFERENCES `%susers` (`auth`) ON UPDATE RESTRICT ON DELETE RESTRICT;", gS_SQLPrefix, gS_SQLPrefix, gS_SQLPrefix);
|
||||
AddQueryLog(trans, sQuery);
|
||||
}
|
||||
else
|
||||
{
|
||||
results.FetchRow();
|
||||
|
||||
char sPlayertimesMasterSQL[1024];
|
||||
results.FetchString(0, sPlayertimesMasterSQL, sizeof(sPlayertimesMasterSQL));
|
||||
|
||||
@ -645,6 +651,13 @@ public void SQL_TableMigrationPlayertimesAuthFK_Callback(Database db, DBResultSe
|
||||
if (StrContains(sPlayertimesMasterSQL, sConstraintTest) == -1 // >= v3.1.0
|
||||
|| StrContains(sPlayertimesMasterSQL, "(`auth`) ON UPDATE CASCADE ON DELETE CASCADE") != -1) // <= v3.0.8
|
||||
{
|
||||
// add missing users to users table
|
||||
FormatEx(sQuery, sizeof(sQuery),
|
||||
"INSERT INTO `%susers` (auth) SELECT p1.auth FROM `%splayertimes` p1 LEFT JOIN `%susers` u1 ON u1.auth = p1.auth WHERE u1.auth IS NULL;",
|
||||
gS_SQLPrefix, gS_SQLPrefix, gS_SQLPrefix
|
||||
);
|
||||
AddQueryLog(trans, sQuery);
|
||||
|
||||
FormatEx(sQuery, sizeof(sQuery), "CREATE TEMPORARY TABLE temp_pt AS SELECT * FROM `%splayertimes`;", gS_SQLPrefix);
|
||||
AddQueryLog(trans, sQuery);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user