Problem
I've two databases, mainDb and secondDb, which I need to merge into a single database during a database upgrade (migration).
Attempts
I've looked into createFromAsset() which allows to import data from a database, but this only seems to work with fallbackToDestructiveMigration() enabled which would clear my mainDb when loading createFromAsset(secondDb).
Perhaps consider this example, noting that the answer you have given has some issues:-
The Database code (
@Daos,@Databases,@Entities) for the 2 databases:-
Some Activity Code to load some data into both databases for retention :-
When run (1 or more times due the the version/row count test):-
The Log shows:-
App Inspection Shows:-
and also :-
The Merge
The Database Code becomes :-
The Activity Code becomes:-
Merged Results*
The Log :-
i.e. ALL data retained
And via App Inspection:-
and