mirror of
https://github.com/songoda/SongodaCore.git
synced 2025-01-25 00:31:22 +01:00
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:
parent
adcf8619ec
commit
0e8f52b1be
@ -163,7 +163,8 @@ public class DataManager {
|
||||
}
|
||||
} else {
|
||||
// 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)) {
|
||||
ResultSet result = statement.executeQuery();
|
||||
result.next();
|
||||
|
Loading…
Reference in New Issue
Block a user