fix 数据库迁移到 mysql 报错(字段不存在)

This commit is contained in:
bwcx_jzy 2023-03-21 17:52:42 +08:00
parent e6842e5159
commit e1090f987b
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
2 changed files with 17 additions and 16 deletions

View File

@ -14,6 +14,7 @@
(感谢 [@大灰灰大](https://gitee.com/linjianhui) [Gitee issues I6OUDT](https://gitee.com/dromara/Jpom/issues/I6OUDT)
3. 【server】优化 文件管理列表显示,小屏幕部分字段被隐藏(感谢@tinsang
4. 【server】优化 docker 拉取镜像自动解析 tag避免拉取所有镜像如果没有配置 tag 默认使用 latest感谢@Again... .
5. 【server】修复 数据库迁移到 mysql 报错(字段不存在)(感谢@轩辕豆豆)
------

View File

@ -111,16 +111,16 @@ public class StorageServiceFactory {
log.info("成功连接 {} {}", dbExtConfig.getMode(), dbExtConfig.getUrl());
Set<Class<?>> classes = ClassUtil.scanPackageByAnnotation("io.jpom", TableName.class);
classes = classes.stream()
.filter(aClass -> {
TableName tableName = aClass.getAnnotation(TableName.class);
DbExtConfig.Mode[] modes = tableName.modes();
if (ArrayUtil.isEmpty(modes)) {
return true;
}
return ArrayUtil.contains(modes, dbExtConfig.getMode());
})
.sorted((o1, o2) -> StrUtil.compare(o1.getSimpleName(), o2.getSimpleName(), false))
.collect(Collectors.toCollection(LinkedHashSet::new));
.filter(aClass -> {
TableName tableName = aClass.getAnnotation(TableName.class);
DbExtConfig.Mode[] modes = tableName.modes();
if (ArrayUtil.isEmpty(modes)) {
return true;
}
return ArrayUtil.contains(modes, dbExtConfig.getMode());
})
.sorted((o1, o2) -> StrUtil.compare(o1.getSimpleName(), o2.getSimpleName(), false))
.collect(Collectors.toCollection(LinkedHashSet::new));
log.info("准备迁移数据");
int total = 0;
for (Class<?> aClass : classes) {
@ -153,12 +153,12 @@ public class StorageServiceFactory {
}
// 过滤需要忽略迁移的数据
List<Entity> newResult = pageResult.stream()
.map(entity -> entity.toBeanIgnoreCase(aClass))
.map(o -> {
// 兼容大小写
Entity entity = Entity.create(tableName.value());
return entity.parseBean(o);
}).collect(Collectors.toList());
.map(entity -> entity.toBeanIgnoreCase(aClass))
.map(o -> {
// 兼容大小写
Entity entity = Entity.create(tableName.value());
return entity.parseBean(o, false, true);
}).collect(Collectors.toList());
if (newResult.isEmpty()) {
if (pageResult.isLast()) {
// 最后一页