I am adding UNIQUE constrains for 2 of my DB table’s columns so that each rows of the table could be unique. And so along with adding UNIQUE constrains I am also performing DB migration as below:
static final Migration MIGRATION_1_2 = new Migration(1, 2) {
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL(“CREATE UNIQUE INDEX index_<MyTableName>_<ColumnName> ON <MyTableName> (<ColumnName>)”);
}
};
But Getting bellow crash:
Fatal Exception: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: . (code 2067) at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(SQLiteConnection.java) at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:734) at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754) at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64) at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1677)
Note: One of the reason (But not sure) may be: As I am using "room:runtime:1.1.0" which has some issue related with it (Ref:https://issuetracker.google.com/issues/79362399) , So should I migrate to "room:runtime:1.1.1-rc1" ?
Any pointer on the above issue would be highly appreciated.
Thanks You.