I used SugarORM in my application's first release. Now, I'm working on the 2nd release, which has new tables added to DB.
According to SugarORM documentation "Sugar will automatically create tables for new entities, so your migration script only needs to cater for alterations to existing tables."
Here's what I done:
- Increased the DB version in the AndroidManifest
<meta-data android:name="VERSION" android:value="2" />
- Created the new record class.
public class NewModel extends SugarRecord<NewModel>
When ran the app, Sugar created the new table, but unfortunately, it also dropped/created existing tables, erasing all data saved locally!
I also tried to create the new table myself, by adding a migration script file 2.sql
which contains my CREATE TABLE NEW_MODEL
statement. Unfortunately too, it threw an exception "Table already exists" because Sugar created the new table and then tried to run my script!
Any suggestions?