Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
k-kagurazaka opened this issue Jan 26, 2018 · 2 comments · Fixed by #469
Closed

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

k-kagurazaka opened this issue Jan 26, 2018 · 2 comments · Fixed by #469
Labels

Comments

@k-kagurazaka
Copy link
Member

k-kagurazaka commented Jan 26, 2018

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.

@gfx gfx added the bug label Apr 3, 2018
@gfx gfx changed the title Ignore ManualStepMigration at the first time ManualStepMigration is ignored at the first time (i.e. when DB version is 0) Oct 7, 2018
@gfx gfx removed the bug label Oct 8, 2018
@gfx gfx added this to the v6 milestone Oct 8, 2018
@k-kagurazaka
Copy link
Member Author

k-kagurazaka commented Oct 10, 2018

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 added a commit that referenced this issue Oct 28, 2018
@gfx gfx added the bug label Oct 28, 2018
@gfx gfx removed this from the v6 milestone Oct 29, 2018
gfx added a commit that referenced this issue Oct 29, 2018
@gfx gfx closed this as completed in #469 Oct 29, 2018
gfx added a commit that referenced this issue Oct 29, 2018
Fix #436: ManualStepMigration not working
@gfx
Copy link
Member

gfx commented Oct 29, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants