I have implemented the Room database in my Application with few tables. Now I have to add another table in my database as the requirement has been updated. The problem I am facing is that when I execute the code with column type boolean App crashes. My entity class model is as below
@Entity(tableName = Constants.TABLE_NAME_CONVERSATION)
public class ConversationModel {
@PrimaryKey(autoGenerate = true)
private int id;
String inputWord, translatedWord,origin,targetLangCode;
boolean isSpeaking;
public ConversationModel() {
}
}
The migration code I have written is :
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
@Override
public void migrate(SupportSQLiteDatabase database) {
String createTable = "CREATE TABLE IF NOT EXISTS 'conversation' (id INTEGER NOT NULL PRIMARY KEY, inputWord TEXT, translatedWord TEXT, origin TEXT, targetLangCode TEXT, isSpeaking BOOLEAN)";
database.execSQL(createTable);
}
};
And the crash log I am receiving is this:
Caused by: java.lang.IllegalStateException: Migration didn't properly handle conversation(com.translateall.language.free.translator.dictionary.speechtext.learnenglish.models.ConversationModel).
Expected:
TableInfo{name='conversation', columns={isSpeaking=Column{name='isSpeaking',type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0}}, foreignKeys=[], indices=[]}
Found:
2019-10-29 13:24:31.433 20525-20525/com.translateall.language.free.translator.dictionary.speechtext.learnenglish E/AndroidRuntime:TableInfo{name='conversation', columns={
isSpeaking=Column{name='isSpeaking', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0}}, foreignKeys=[], indices=[]}
My model class has boolean type item. Why it is expecting integer type?