#792 Force migration of SQLite when necessary (#1371)

- Detect if a migration is necessary
- Create a backup
- Perform the migration
This commit is contained in:
ljacqu
2017-10-22 09:16:48 +02:00
committed by GitHub
parent c37c0ce436
commit d6e2369f36
12 changed files with 234 additions and 260 deletions
@@ -3,9 +3,11 @@ package fr.xephi.authme.datasource.converter;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.datasource.SQLite;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.settings.Settings;
import javax.inject.Inject;
import java.io.File;
import java.sql.SQLException;
/**
@@ -14,15 +16,17 @@ import java.sql.SQLException;
public class SqliteToSql extends AbstractDataSourceConverter<SQLite> {
private final Settings settings;
private final File dataFolder;
@Inject
SqliteToSql(Settings settings, DataSource dataSource) {
SqliteToSql(Settings settings, DataSource dataSource, @DataFolder File dataFolder) {
super(dataSource, DataSourceType.MYSQL);
this.settings = settings;
this.dataFolder = dataFolder;
}
@Override
protected SQLite getSource() throws SQLException, ClassNotFoundException {
return new SQLite(settings);
protected SQLite getSource() throws SQLException {
return new SQLite(settings, dataFolder);
}
}