Updating model with DBFlow

422 views Asked by At

I'm using the ORM DbFlow in my app, and i changed a column in a table class.

To get the DBFlow internal classes rebuilt with the new column, I tried incrementing the database version but the ****_Table class that we use in the queries hasn't been updated and still has the columns of the previous version.

@Database(name = MyDatabase.NAME, version = MyDatabase.VERSION)
public class MyDatabase {

public static final String NAME = "Releves";
//incremented the database version from 2 to 3
public static final int VERSION = 3;

Do you know how to make it do the update so i can make my query ?

Thank you

2

There are 2 answers

0
Ramees Thattarath On

Possible reason is that classes auto generated by dbflow might be still present, Try clean and rebuild the project - if this did not work, try invalidate cache and restart (File -> Invalidate cache and restart)

0
Reza On

class1:

public class DatabaseDBFlow extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        FlowManager.init(this);
    }

Manifest--> android:name=".DatabaseDBFlow"

class2:

@Database(name = AppDatabase.NAME, version = AppDatabase.VERSION)
public class AppDatabase {
    public static final String NAME = "AppDatabase";

    public static final int VERSION = 1;
}

and class Database:

@Table(database = AppDatabase.class)
public class InformationDB_Theme extends BaseModel {

    @PrimaryKey(autoincrement = true)
    public int ID;
    @Column
    public String NAME;
}