2

I'm using Activeandroid 3.1.0 to store some of my data in databases. Some days ago I needed to update a table to add another column.

Workflow: Increment the DB Version from 1 to 2:

<meta-data
    android:name="AA_DB_NAME"
    android:value="sqlite.db"/>
<meta-data
    android:name="AA_DB_VERSION"
    android:value="2"/>

Add a new column in the model:

  @Column(name = "test_column") private boolean test_column;

Write a migration Script:

ALTER TABLE #TABLENAME# ADD COLUMN test_column INTEGER;

I've searched in the library and found that java's boolean variables and converted into integer.

This script is located under:

app/src/main/assets/migrations/2.sql

Test Usecase: Save some elements -> Update with steps explained above -> Save some elements and use the column

Problem: If I test this locally by just loading the application onto my phone directly it works but when I upload the application with the migration to the playstore it does not work. I get the typical "No such column"-Error.

Does anyone know if the migration script is not shipped to the final apk through the store? I thought that proguard could possible remove the file but it works with proguard and the release version locally too. This error costed me a lot of crashes in a production application until I removed the column as a quick fix.

Hope someone has an idea :)

Matthias
  • 158
  • 1
  • 11
  • are you sure that store app db version is not 2 already? – Yazan Mar 08 '16 at 14:12
  • I restored all of my Releases and collected the db Data and I can see that db version was set to 1 in all prior releases. The currently working quickfix with the removed column annotation is set to version 2 too. I could probably update the application with a third version but fear to get an "column already available"-error on some devices. Its not possible for me to inspect the databases of the clients... – Matthias Mar 08 '16 at 15:48
  • you can inspect table's fields using many ways, such as this question http://stackoverflow.com/questions/4550896/return-all-columns-of-a-sqlite-table-in-android you can increase db-version to 3 or 4 and `onUpgrade()` inspect the table and do what you need – Yazan Mar 09 '16 at 07:49

0 Answers0