Fix issue checking if the migration table exists or not

This commit is contained in:
ceze88 2023-09-04 20:02:53 +02:00
parent 10f0d28673
commit 204677c3a9

View File

@ -147,9 +147,15 @@ public class DataManager {
int currentMigration = -1; int currentMigration = -1;
boolean migrationsExist; boolean migrationsExist;
DatabaseMetaData meta = connection.getMetaData(); // DatabaseMetaData meta = connection.getMetaData();
ResultSet res = meta.getTables(null, null, this.getMigrationsTableName(), new String[] {"TABLE"}); // ResultSet res = meta.getTables(null, null, this.getMigrationsTableName(), new String[] {"TABLE"});
migrationsExist = res.next(); // migrationsExist = res.next();
try {
connection.createStatement().execute("SELECT 1 FROM " + this.getMigrationsTableName());
migrationsExist = true;
} catch (Exception ex) {
migrationsExist = false;
}
if (!migrationsExist) { if (!migrationsExist) {
// No migration table exists, create one // No migration table exists, create one