|
@@ -11176,5 +11176,19 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
|
|
|
// 列已存在,忽略
|
|
// 列已存在,忽略
|
|
|
log.warn("迁移313: octopus_effect_record.happened_at 列已存在或添加失败: {}", e.getMessage());
|
|
log.warn("迁移313: octopus_effect_record.happened_at 列已存在或添加失败: {}", e.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 迁移314: 回填 article_reading_records 表中 article_id 为 NULL 的老记录
|
|
|
|
|
+ // 通过 task 表关联恢复:record.task_id → task.source_type='article' → task.source_id
|
|
|
|
|
+ try {
|
|
|
|
|
+ int updated = jdbcTemplate.update(
|
|
|
|
|
+ "UPDATE article_reading_records r " +
|
|
|
|
|
+ "LEFT JOIN tasks t ON r.task_id = t.id AND t.source_type = 'article' " +
|
|
|
|
|
+ "SET r.article_id = t.source_id " +
|
|
|
|
|
+ "WHERE r.article_id IS NULL AND t.id IS NOT NULL AND t.source_id IS NOT NULL"
|
|
|
|
|
+ );
|
|
|
|
|
+ log.info("迁移314: 已回填 article_reading_records.article_id {} 条记录", updated);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("迁移314: 回填 article_reading_records.article_id 失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|