add new data_version column to server_info table
This commit is contained in:
parent
3d2eb77db1
commit
b2f3aa5497
|
|
@ -1,6 +1,7 @@
|
||||||
package vip.fubuki.playersync;
|
package vip.fubuki.playersync;
|
||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
|
import net.minecraft.SharedConstants;
|
||||||
import net.neoforged.bus.api.IEventBus;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.ModList;
|
import net.neoforged.fml.ModList;
|
||||||
|
|
@ -111,28 +112,37 @@ public class PlayerSync {
|
||||||
"PRIMARY KEY (`id`)" +
|
"PRIMARY KEY (`id`)" +
|
||||||
");"
|
");"
|
||||||
);
|
);
|
||||||
|
// do not modify the create table statement to make sure this code is compatible with older database versions
|
||||||
|
addColumnIfNotExists("server_info", "data_version", "INT NOT NULL DEFAULT 0");
|
||||||
|
|
||||||
long current = System.currentTimeMillis();
|
long current = System.currentTimeMillis();
|
||||||
|
int data_version = SharedConstants.getCurrentVersion().getDataVersion().getVersion();
|
||||||
JDBCsetUp.executeUpdate("""
|
JDBCsetUp.executeUpdate("""
|
||||||
INSERT INTO %s.server_info
|
INSERT INTO %s.server_info
|
||||||
(
|
(
|
||||||
id,
|
id,
|
||||||
enable,
|
enable,
|
||||||
|
data_version,
|
||||||
last_update
|
last_update
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
%d,
|
%d,
|
||||||
true,
|
true,
|
||||||
|
%d,
|
||||||
%d
|
%d
|
||||||
)
|
)
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
id = %d,
|
id = %d,
|
||||||
enable = true,
|
enable = true,
|
||||||
|
data_version = %d,
|
||||||
last_update = %d;
|
last_update = %d;
|
||||||
""",
|
""",
|
||||||
dbName,
|
dbName,
|
||||||
JdbcConfig.SERVER_ID.get(),
|
JdbcConfig.SERVER_ID.get(),
|
||||||
|
data_version,
|
||||||
current,
|
current,
|
||||||
JdbcConfig.SERVER_ID.get(),
|
JdbcConfig.SERVER_ID.get(),
|
||||||
|
data_version,
|
||||||
current);
|
current);
|
||||||
|
|
||||||
// Create curios table if the Curios mod is loaded
|
// Create curios table if the Curios mod is loaded
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user