mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-07 19:28:11 +01:00
Prevent problems migrating to SQLite
This commit is contained in:
parent
fb3c94d17d
commit
d01f91edc9
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 GeorgH93
|
||||
* Copyright (C) 2020 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -28,6 +28,7 @@
|
||||
import org.intellij.lang.annotations.Language;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.DateFormat;
|
||||
@ -59,7 +60,11 @@ protected ToSQLMigration(@NotNull Minepacks plugin, @NotNull Database oldDb, @No
|
||||
switch(dbType)
|
||||
{
|
||||
case "mysql": newDb = new MySQL(plugin, connectionProvider); break;
|
||||
case "sqlite": newDb = new SQLite(plugin, connectionProvider); break;
|
||||
case "sqlite":
|
||||
final File dbFile = new File(SQLite.getDbFile(plugin));
|
||||
if(dbFile.exists()) dbFile.renameTo(new File(SQLite.getDbFile(plugin) + ".old_" + System.currentTimeMillis()));
|
||||
newDb = new SQLite(plugin, connectionProvider);
|
||||
break;
|
||||
default: newDb = null;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 GeorgH93
|
||||
* Copyright (C) 2020 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -34,10 +34,15 @@
|
||||
|
||||
public class SQLite extends SQL
|
||||
{
|
||||
//TODO add cooldown sync table
|
||||
public SQLite(@NotNull Minepacks plugin, @Nullable ConnectionProvider connectionProvider)
|
||||
public static String getDbFile(final @NotNull Minepacks plugin)
|
||||
{
|
||||
super(plugin, (connectionProvider == null) ? new SQLiteConnectionProvider(plugin.getLogger(), plugin.getDescription().getName(), plugin.getDataFolder().getAbsolutePath() + File.separator + "backpack.db") : connectionProvider);
|
||||
return plugin.getDataFolder().getAbsolutePath() + File.separator + "backpack.db";
|
||||
}
|
||||
|
||||
//TODO add cooldown sync table
|
||||
public SQLite(final @NotNull Minepacks plugin, final @Nullable ConnectionProvider connectionProvider)
|
||||
{
|
||||
super(plugin, (connectionProvider == null) ? new SQLiteConnectionProvider(plugin.getLogger(), plugin.getDescription().getName(), getDbFile(plugin)) : connectionProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user