humazed / RoomAsset

A helper library to help using Room with existing pre-populated database [DEPRECATED].
Apache License 2.0
135 stars 23 forks source link

Failed database migration validation #4

Closed MrLepage closed 6 years ago

MrLepage commented 6 years ago

When I try to open the database for the first time with RoomAsset, the migration validation fails. I see that the columns order is not the same between what is expected and what is found. I don't know how the columns order are determined.

java.lang.IllegalStateException: Migration didn't properly handle products(com.garnier.garnier.manager.catalog.database.entities.Product).

Expected: TableInfo{name='products', columns={description=Column{name='description', type='TEXT', notNull=false, primaryKeyPosition=0}, tutorialUrl=Column{name='tutorialUrl', type='TEXT', notNull=false, primaryKeyPosition=0}, id=Column{name='id', type='INTEGER', notNull=true, primaryKeyPosition=1}, eanBarcode=Column{name='eanBarcode', type='INTEGER', notNull=false, primaryKeyPosition=0}, brandId=Column{name='brandId', type='INTEGER', notNull=false, primaryKeyPosition=0}, name=Column{name='name', type='TEXT', notNull=false, primaryKeyPosition=0}, shadeId=Column{name='shadeId', type='INTEGER', notNull=false, primaryKeyPosition=0}}, foreignKeys=[], indices=[]}
Found: TableInfo{name='products', columns={tutorialURL=Column{name='tutorialURL', type='TEXT', notNull=false, primaryKeyPosition=0}, description=Column{name='description', type='TEXT', notNull=false, primaryKeyPosition=0}, eanBarcode=Column{name='eanBarcode', type='INTEGER', notNull=false, primaryKeyPosition=0}, id=Column{name='id', type='INTEGER', notNull=true, primaryKeyPosition=1}, name=Column{name='name', type='TEXT', notNull=false, primaryKeyPosition=0}, brandId=Column{name='brandId', type='INTEGER', notNull=false, primaryKeyPosition=0}, shadeId=Column{name='shadeId', type='INTEGER', notNull=false, primaryKeyPosition=0}}, foreignKeys=[], indices=[]}
humazed commented 6 years ago

As in #1 Expected: the Dao class. Found: The actual database.

columns order doesn't matter as long you ensures the types are the same

MrLepage commented 6 years ago

If you compare Expected and Found in my previous post you will see that the type are the same for each column.

Not null field is the same for each column too.

The only difference between the two is the order if the columns in TableInfo

MrLepage commented 6 years ago

I just see that "tutorialUrl" is expected with url in uppercase...

humazed commented 6 years ago

SQL should be case insensitive I'm not sure if it's your problem. try to rename to tutorialURL and let me know what happened

MrLepage commented 6 years ago

Thanks for making me check twice ;)

MrLepage commented 6 years ago

My Product Entity had the wrong column name. Problem fixed.

humazed commented 6 years ago

interesting, so room is case sensitive. glad you solve your problem.