Closed petroski77 closed 9 years ago
Can you send me your migration class to see if I can spot anything wrong?
The migrations works fine if the database is already created and I go from version 1 to 2. The problem only occurs in the initial state where the database is not yet created.
AppDatabase class:
@Database(name = AppDatabase.NAME, version = AppDatabase.VERSION, foreignKeysSupported = true)
public class AppDatabase {
public static final String NAME = "SHelperDB";
public static final int VERSION = 1;
}
Migration class:
@Migration(version = 1, databaseName = AppDatabase.NAME)
public class MigrationNameIndex extends IndexMigration<ShoppingList> {
public MigrationNameIndex() {
super("nameIdx",ShoppingList.class);
}
@Override
public void onPreMigrate() {
super.onPreMigrate();
addColumn(ShoppingList$Table.NAME);
}
}
@agrosner any news?
I guess another problem also would be If I create an android app, and it goes through 7 database versions, and thus the database schema changes, how does one ensure that the currently available app on google play contains the previous migrations (indexes and so on)?
Ok maybe I have figured this one out ;) On initial release do the following:
On later releases
//Christian
hey sorry for taking so long to get back to you @petroski77 . on app launch, the library iterates through each migration version in succession and version order until the most recent version of the app is satisfied. Ok so a version 0 migration works? let me know and I can add this to the documentation.
Hi @agrosner No worries :)
Ok so a version 0 migration works?
Yes, that definitely seems to be the case.
//Christian
Hi @agrosner confirming that this is also working OK with my application, so you can add it to the documentation.
This appears to be too hacky. Really the indexes createIfNotExist should be called without going through migration.
Hey
I'm having a hard time figuring out where to define the indexes for my tables especially if the app hasn't been released yet.
It would be cool if one could have an initial migration where indexes, triggers and so on could be defined for the initial release/version.
I was kinda hoping that if I defined the database as having version 1 and then added a migration with version 1 that it would work, but unfortunately the migration doesn't get called.
Am I missing something here?
Best regards Christian