diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/ToSQLMigration.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/ToSQLMigration.java index 5ea2ce9..b18ca45 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/ToSQLMigration.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Migration/ToSQLMigration.java @@ -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; } } diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/SQLite.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/SQLite.java index 3dde84f..ae77207 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/SQLite.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/SQLite.java @@ -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 diff --git a/pom.xml b/pom.xml index cf83ba9..04635df 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ pom - 2.3.6 + 2.3.7-RC1 UTF-8 UTF-8