maskarade/Android-Orma

ManualStepMigration is ignored at the first time (i.e. when DB version is 0)

Closed this issue · 2 comments

Overview

ManualStepMigration doesn't run if the dbVersion is 0 (See this code).
However, Database#setVersion is called at only ManualStepMigration class, so when we add the first manual migration step to a project, the step will be ignored since the default dbVersion is 0.

I pushed a repository to reproduce this issue (https://github.com/k-kagurazaka/orma-migration-issue).

Reproducing step is following:

  1. Run the app
  2. Change versionCode in app/build.gradle to 2
  3. Rebuild and run the app
  4. This line is never called

Cause of this issue is that db version is still 0 after step 1 since OrmaConnection#migrationEngine is SchemaDiffMigration (not OrmaMigration) when OrmaDatabase.Builder#migrationStep is not called.

gfx commented

As described in #469, there were two independent issues on it:

  • ManualStepMigration was not invoked if no migration step was defined, and thus the DB version was not initialized.
  • ManualStepMigration did not update the DB version if migration steps did not call execSQL and its wrappers (it was rare cases in production, though)

A new version 6.0.2 fixes these issues.