mardi 8 mars 2016

Table Migration crashes with store update but works locally

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 :)

Aucun commentaire:

Enregistrer un commentaire