android - Could not migrate to Room -
i decided use room in current application. find out there no type 1 column in current schema , room produce illegalstateexception
on migration.
java.lang.illegalstateexception: migration didn't handle item. expected: tableinfo{name='item', columns={optional_modifiers=column{a_type=column{name='a_type', type='blob', notnull=false, primarykeyposition=0}...} found: tableinfo{name='item', columns={optional_modifiers=column{a_type=column{name='a_type', type='', notnull=false, primarykeyposition=0}...}
sql script of table creation:
"create table item (" " id text primary key," + " a_type, " //... ")
entity class:
@entity(tablename = "item") data class item( @primarykey val id: string?, val a_type: string? // used several types, none of them worked )
are there way resolve issue?
make modification class annotated @entity below.
@entity(tablename = "item") data class item( @primarykey val id: string?, @columninfo(typeaffinity = columninfo.blob) val a_type: string? )
this work, because error visible old db schema having name='a_type', type='blob', need add @columninfo(typeaffinity = columninfo.blob) instruct room consider data type of "a_type" blob.
recently comes attention @columninfo provide "undefined" type affinity can declare table field without type.documentation
please try updated changes in project.
@entity(tablename = "item") data class item( @primarykey val id: string?, @columninfo(typeaffinity = columninfo.undefined) val a_type: string? )
Comments
Post a Comment