I want to write a migration script for dbflow (v4+).. I want to delete all the previous tables and then build everything from scratch. Currently only way I found we can do this is like:
@Migration(version = 2, database = AppDatabase.class)
public static class Migration2 extends BaseMigration {
@Override
public void migrate(DatabaseWrapper database) {
ArrayList<ModelAdapter> modelAdapters = new ArrayList<>();
// Old tables
modelAdapters.add(FlowManager.getModelAdapter(Events.class));
modelAdapters.add(FlowManager.getModelAdapter(Notes.class));
// New table
modelAdapters.add(FlowManager.getModelAdapter(User.class));
for (ModelAdapter modelAdapter : modelAdapters) {
database.execSQL("DROP TABLE IF EXISTS " + modelAdapter.getTableName());
database.execSQL(modelAdapter.getCreationQuery());
}
}
}
I don't like this approach though as we have to manually mention all the old and new tables. Is there a better way to do it. My db has changed significantly and therefore dropping all tables seems to be the only option.