Implement workaround for migrated SQLite databases applying migrations

The migration version -1 is already written into the new database before the old one has been converted.
This causes the migration to be run on the converted database because in addition to the migrated
version (e.g. 8) the -1 is already written to the table.
And now you just need to be kind of lucky to not retrieve that wrong version.

Just a hacky workaround (I know)
This commit is contained in:
Christian Koop 2024-01-15 21:07:54 +01:00
parent adcf8619ec
commit 0e8f52b1be
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3

View File

@ -163,7 +163,8 @@ public class DataManager {
} }
} else { } else {
// Grab the current migration version // Grab the current migration version
String selectVersion = "SELECT migration_version FROM " + this.getMigrationsTableName(); // Due to the automatic SQLite to H2 conversion that might have happened, two entries (one of them -1) might exist
String selectVersion = "SELECT migration_version FROM " + this.getMigrationsTableName() + " ORDER BY migration_version DESC LIMIT 1";
try (PreparedStatement statement = connection.prepareStatement(selectVersion)) { try (PreparedStatement statement = connection.prepareStatement(selectVersion)) {
ResultSet result = statement.executeQuery(); ResultSet result = statement.executeQuery();
result.next(); result.next();