Search code examples
androidormactiveandroid

ActiveAndroid: Upgrade Database version


I have the following scenario: My app is published with database version 4 to the customers.

I did some bugfixes and added some more features. This process also changed my models and thats why the database changed too.

How can I check what database version the customer has installed on his devices and migrate the old data to the new database? Is there an onUpgrade method or something like this in the ActiveAndroid Library?


Solution

  • After taking a deeper look into ActiveAndroid's sourcecode I found a solution. ActiveAndroid can use sql-scripts located in your asset folder to migrate from one version to another.

    It sorts all your sql files located in assets/migrations/ using a natural sorting algorithm:

    Each SQL script which was found will be executed if its > oldVersion and <= newVersion