Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Room change type of column with Migration

I didn't find any answer to what I'm searching for so I'm sending this question.

I am using Room for Android.

I have an Entity with an Int column and I need to change it to Double, and I don't know how to do it.

Does anybody know how to do it?

My question might be dumb, but I didn't find any answer on stackoverflow/any google search.

like image 962
A.Danibo Avatar asked Dec 13 '22 13:12

A.Danibo


1 Answers

You need to create new table with the new schema. Copy data from old table to the new one. Drop old table. Rename new table to the name of old table.

Here you've got nice article about that: https://medium.com/androiddevelopers/understanding-migrations-with-room-f01e04b07929

like image 177
Sebastian M Avatar answered Dec 26 '22 17:12

Sebastian M