0

I am using DBFLOW library, I have prepacked database. now I want to add new data to my database in two tables, when I increase the version database and update my app, the old version of the database is still showing. I think I should use Migration, but I don't know how to use it when I just change some data without rename or add columns.

@Database(name = BookDatabase.NAME, version = BookDatabase.VERSION, foreignKeysSupported = true, backupEnabled = true, consistencyCheckEnabled = true)

public class BookDatabase {
    public static final String NAME = "book_list";
    public static final int VERSION = 2;

    @Migration(version = 2, database = BookDatabase.class)
    public static class Migration2 extends BaseMigration {

        @Override
        public void migrate(DatabaseWrapper database) {

//            I don't know what should I write here !!
        }
    }
}
ali johar
  • 13
  • 5
  • Database migrations are typically used for database schema changes, not data updates. Did you have a chance to look through the documentation, there're some examples there: https://github.com/agrosner/DBFlow/blob/master/usage2/usage/migrations.md – maksimov Jun 05 '19 at 12:41
  • My problem is only data, the strange thing is when i update my app all my old data is shown, and i should make clear data to app to see the new data – ali johar Jun 05 '19 at 15:33
  • Primary function of databases is to _keep_ data. If you need your data to be reset to some initial state, you will need to make it so. – maksimov Jun 05 '19 at 17:58
  • No, I don't want to reset data.... in data version 1 I have 35 records in the table. I now want to add 10 new records to my table in the database. when I update my app the app show only 36 records of data until making clear data to replace the new database with the old version. I want to show new app with new database records without the need to make clear data – ali johar Jun 06 '19 at 12:24

0 Answers0