Android Room带有迁移的列更改类型 [英] 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.
我正在使用Room for Android.
I am using Room for Android.
我有一个带有Int列的Entity,我需要将其更改为Double,但我不知道该怎么做.
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.
有人知道怎么做吗?
我的问题可能很愚蠢,但在stackoverflow/任何Google搜索中都找不到任何答案.
My question might be dumb, but I didn't find any answer on stackoverflow/any google search.
推荐答案
您需要使用新架构创建新表. 将数据从旧表复制到新表. 放下旧桌子. 将新表重命名为旧表的名称.
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.
在这里,您可以找到有关以下内容的不错的文章: https://medium.com/androiddevelopers/understanding-migrations-with-room-f01e04b07929
Here you've got nice article about that: https://medium.com/androiddevelopers/understanding-migrations-with-room-f01e04b07929
这篇关于Android Room带有迁移的列更改类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!