Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 54665f58 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #4113 from k9mail/downgrade_exception

Throw exception when a database downgrade situation is encountered
parents 243dd318 52cb690d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -35,6 +35,11 @@ public class K9StoragePersister implements StoragePersister {

        db.beginTransaction();
        try {
            if (db.getVersion() > DB_VERSION) {
                throw new AssertionError("Database downgrades are not supported. " +
                        "Please fix the database '" + DB_NAME + "' manually or clear app data.");
            }

            if (db.getVersion() < 1) {
                createStorageDatabase(db);
            } else {
+7 −0
Original line number Diff line number Diff line
@@ -46,6 +46,13 @@ class StoreSchemaDefinition implements SchemaDefinition {

        db.beginTransaction();
        try {
            if (db.getVersion() > DB_VERSION) {
                String accountUuid = migrationsHelper.getAccount().getUuid();
                throw new AssertionError("Database downgrades are not supported. " +
                        "Please fix the account database '" + accountUuid + "' manually or " +
                        "clear app data.");
            }

            // schema version 29 was when we moved to incremental updates
            // in the case of a new db or a < v29 db, we blow away and start from scratch
            if (db.getVersion() < 29) {