android mysql移植_迁移室数据库,改变表,android?

在我的应用程序中,我使用房间数据库来保存一些数据。

我在版本1中有带有一些列的表userinfo。

后来我在数据库中添加了一个整型列,升级了数据库版本,添加了迁移代码,但我在下面得到了这个异常

Migration didn't properly handle UserInfo(ima.rvtech.model.api.result.UserInfo).

Expected:

TableInfo{name='UserInfo', columns={

address=Column{name='address', type='TEXT', notNull=false, primaryKeyPosition=0},

password=Column{name='password', type='TEXT', notNull=false, primaryKeyPosition=0},

actBy=Column{name='actBy', type='TEXT', notNull=false, primaryKeyPosition=0},

emailId=Column{name='emailId', type='TEXT', notNull=false, primaryKeyPosition=0},

userType=Column{name='userType', type='TEXT', notNull=false, primaryKeyPosition=0},

pinCode=Column{name='pinCode', type='TEXT', notNull=false, primaryKeyPosition=0},

uploadImagePath=Column{name='uploadImagePath', type='TEXT', notNull=false, primaryKeyPosition=0},

loginId=Column{name='loginId', type='TEXT', notNull=false, primaryKeyPosition=0},

actDate=Column{name='actDate', type='TEXT', notNull=false, primaryKeyPosition=0},

contactNo=Column{name='contactNo', type='TEXT', notNull=false, primaryKeyPosition=0},

uploadVideoPath=Column{name='uploadVideoPath', type='TEXT', notNull=false, primaryKeyPosition=0},

edbNo=Column{name='edbNo', type='TEXT', notNull=false, primaryKeyPosition=0},

id=Column{name='id', type='INTEGER', notNull=true, primaryKeyPosition=1},

emergencyContactNo=Column{name='emergencyContactNo', type='TEXT', notNull=false, primaryKeyPosition=0},

bannerImagePath=Column{name='bannerImagePath', type='TEXT', notNull=false, primaryKeyPosition=0},

MyFriendListCount=Column{name='MyFriendListCount', type='INTEGER', notNull=true, primaryKeyPosition=0},

userName=Column{name='userName', type='TEXT', notNull=false, primaryKeyPosition=0},

operationType=Column{name='operationType', type='TEXT', notNull=false, primaryKeyPosition=0}}, foreignKeys=[], indices=[]}

Found:

TableInfo{name='UserInfo', columns={

address=Column{name='address', type='TEXT', notNull=false, primaryKeyPosition=0},

password=Column{name='password', type='TEXT', notNull=false, primaryKeyPosition=0},

actBy=Column{name='actBy', type='TEXT', notNull=false, primaryKeyPosition=0},

emailId=Column{name='emailId', type='TEXT', notNull=false, primaryKeyPosition=0},

userType=Column{name='userType', type='TEXT', notNull=false, primaryKeyPosition=0},

pinCode=Column{name='pinCode', type='TEXT', notNull=false, primaryKeyPosition=0},

uploadImagePath=Column{name='uploadImagePath', type='TEXT', notNull=false, primaryKeyPosition=0},

loginId=Column{name='loginId', type='TEXT', notNull=false, primaryKeyPosition=0},

actDate=Column{name='actDate', type='TEXT', notNull=false, primaryKeyPosition=0},

contactNo=Column{name='contactNo', type='TEXT', notNull=false, primaryKeyPosition=0},

uploadVideoPath=Column{name='uploadVideoPath', type='TEXT', notNull=false, primaryKeyPosition=0},

edbNo=Column{name='edbNo', type='TEXT', notNull=false, primaryKeyPosition=0},

id=Column{name='id', type='INTEGER', notNull=true, primaryKeyPosition=1},

emergencyContactNo=Column{name='emergencyContactNo', type='TEXT', notNull=false, primaryKeyPosition=0},

bannerImagePath=Column{name='bannerImagePath', type='TEXT', notNull=false, primaryKeyPosition=0},

MyFriendListCount=Column{name='MyFriendListCount', type='INTEGER', notNull=false, primaryKeyPosition=0},

userName=Column{name='userName', type='TEXT', notNull=false, primaryKeyPosition=0},

operationType=Column{name='operationType', type='TEXT', notNull=false, primaryKeyPosition=0}}, foreignKeys=[], indices=[]}

我在下一个版本中添加了一个整型列

MyFriendListCount

下面是我的迁移代码

public static final Migration MIGRATION_1_2 = new Migration(1, 2) {

@Override

public void migrate(SupportSQLiteDatabase database) {

database.execSQL("ALTER TABLE UserInfo "

+ " ADD COLUMN MyFriendListCount INTEGER");

}

};

有人能给我指出我这里缺少什么代码吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值