【发布时间】:2021-12-11 13:07:14
【问题描述】:
目前我的数据库版本是5,我已经在数据库表中添加了列并将数据库版本更改为6,并且还添加了从版本5到6的迁移,就像这样
private static final Migration MIGRATION_5_6 = new Migration(5, 6) {
@Override
public void migrate(SupportSQLiteDatabase database) {
try {
database.execSQL("ALTER TABLE generate_data "
+ " ADD COLUMN generateImgPath TEXT");
}catch (Exception e){
e.printStackTrace();
}
}
};
问题:我需要为每个版本制作迁移对象吗?
喜欢
MIGRATION_1_6
MIGRATION_2_6
MIGRATION_3_6
MIGRATION_4_6
MIGRATION_5_6
【问题讨论】:
标签: android android-room database-migration