mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-06 18:08:26 +00:00
Add SQLite statements to re-create mapzones with INTEGER PRIMARY KEY
This commit is contained in:
parent
119e7ff4c8
commit
5f717553d9
@ -575,6 +575,42 @@ public void SQL_FixSQLiteMapzonesROWID_Callback(Database db, DBResultSet results
|
||||
LogError("Timer error! SQLiteMapzonesROWID migration failed. Reason: %s", error);
|
||||
return;
|
||||
}
|
||||
else if (!results.FetchInt(0)) // No NULL ids
|
||||
{
|
||||
InsertMigration(Migration_FixSQLiteMapzonesROWID);
|
||||
return;
|
||||
}
|
||||
|
||||
Transaction trans = new Transaction();
|
||||
char sQuery[512];
|
||||
|
||||
FormatEx(sQuery, sizeof(sQuery), "CREATE TEMPORARY TABLE temp_mapzones AS SELECT * FROM `%smapzones`;", gS_SQLPrefix);
|
||||
AddQueryLog(trans, sQuery);
|
||||
|
||||
FormatEx(sQuery, sizeof(sQuery), "DROP TABLE `%smapzones`;", gS_SQLPrefix);
|
||||
AddQueryLog(trans, sQuery);
|
||||
|
||||
// Re-use mapzones table creation query
|
||||
AddQueryLog(trans, SQLiteMapzonesQuery);
|
||||
|
||||
// Can't do SELECT * FROM temp_mapzones because DBs created < v3.3.0 have an extra `prebuilt` column
|
||||
FormatEx(sQuery, sizeof(sQuery), "INSERT INTO `%smapzones` SELECT `id`, `map`, `type`, `corner1_x`, `corner1_y`, `corner1_z`, `corner2_x`, `corner2_y`, `corner2_z`, `destination_x`, `destination_y`, `destination_z`, `track`, `flags`, `data`, `form`, `target` FROM temp_mapzones;", gS_SQLPrefix);
|
||||
AddQueryLog(trans, sQuery);
|
||||
|
||||
FormatEx(sQuery, sizeof(sQuery), "DROP TABLE `temp_mapzones`;");
|
||||
AddQueryLog(trans, sQuery);
|
||||
|
||||
gH_SQL.Execute(trans, Trans_FixSQLiteMapzonesROWID_Success, Trans_FixSQLiteMapzonesROWID_Error, 0, DBPrio_High);
|
||||
}
|
||||
|
||||
public void Trans_FixSQLiteMapzonesROWID_Success(Database db, any data, int numQueries, DBResultSet[] results, any[] queryData)
|
||||
{
|
||||
InsertMigration(Migration_FixSQLiteMapzonesROWID);
|
||||
}
|
||||
|
||||
public void Trans_FixSQLiteMapzonesROWID_Error(Database db, any data, int numQueries, const char[] error, int failIndex, any[] queryData)
|
||||
{
|
||||
LogError("Timer error! SQLiteMapzonesROWID migration transaction failed. Reason: %s", error);
|
||||
}
|
||||
|
||||
public void SQL_TableMigrationSingleQuery_Callback(Database db, DBResultSet results, const char[] error, any data)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user