ImangazalievM / ReActiveAndroid

🚀 Simple and powerful ORM for Android
MIT License
99 stars 18 forks source link

Data integrity crash #60

Open nscherer opened 5 years ago

nscherer commented 5 years ago

ReActiveAndroid Version: 1.4.3

Bug or Feature Request: Got a data integrity crash after updating data model and database version

Description:

java.lang.IllegalStateException: ReActiveAndroid cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.
        at com.reactiveandroid.internal.database.ReActiveOpenHelper.checkIdentity(ReActiveOpenHelper.java:71)
        at com.reactiveandroid.internal.database.ReActiveOpenHelper.onOpen(ReActiveOpenHelper.java:51)
        at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:411)
        at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:298)
        at com.reactiveandroid.internal.database.DatabaseInfo.getWritableDatabase(DatabaseInfo.java:65)
        at com.reactiveandroid.ReActiveAndroid.getWritableDatabaseForTable(ReActiveAndroid.java:131)
        at com.reactiveandroid.internal.utils.QueryUtils.execSQL(QueryUtils.java:27)
        at com.reactiveandroid.query.ExecutableQueryBase.execute(ExecutableQueryBase.java:21)

I deleted a field from my model, and incremented the database version:

@Database(name = "propertyforce", version = 19)
public class AppDatabase {

It was 18 before. Here's how I'm initializing:

DatabaseConfig appDatabase = new DatabaseConfig.Builder(AppDatabase.class)
                        .addModelClasses(LogEntry.class, FarmReport.class, FarmReportProperty.class)
                        .disableMigrationsChecking() // Potentially destructive, so replace with migrations if adding any tables that need to persist
                        .addTypeSerializers(JsonSerializer.class)
                        .build();
                ReActiveAndroid.init(new ReActiveConfig.Builder(context)
                        .addDatabaseConfigs(appDatabase)
                        .build());

So I shouldn't need any migrations. Why is this happening?

Rensodiaz commented 5 years ago

Same page here, increasing the version number is not working at all. Thanks for helping.