|
|
@@ -54,13 +54,23 @@ namespace IvfTl.Control.Services
|
|
|
// (M2-04 的标定镜像写入此表;本地库原无该表 → 写入失败无数据)。
|
|
|
// InitTables 发 CREATE TABLE IF NOT EXISTS,已建则不动;单独 try 包裹,
|
|
|
// 建表失败不阻断 DB 服务启动(与既有防御式风格一致)。
|
|
|
- try
|
|
|
- {
|
|
|
- Db.CodeFirst.InitTables(typeof(HouseAutofocusCalibrationDB));
|
|
|
- }
|
|
|
- catch (Exception exTable)
|
|
|
+ // D1-09 修复:本地 aivfoTL.db schema 落后于实体(多表缺列,如 tl_setting.localAutofocusEnabled、
|
|
|
+ // house_well_setting 缺列等)→ control 各 Update/Query 报 "no such column"。
|
|
|
+ // CodeFirst.InitTables 对已存在表只补缺失列(additive,ADD COLUMN,不删列不丢数据),逐实体自愈本地 schema;
|
|
|
+ // 每实体独立 try/catch,单表失败(如 SQLite ADD NOT NULL 列限制)不影响其它表与 DB 服务启动。
|
|
|
+ var localEntities = new[]
|
|
|
+ {
|
|
|
+ typeof(HouseAutofocusCalibrationDB), typeof(TLSettingDB), typeof(HouseDB),
|
|
|
+ typeof(HouseWellSettingDB), typeof(DishDB), typeof(BalanceDB),
|
|
|
+ typeof(EmbryoDB), typeof(HouseWellPhotoDB), typeof(PictureDB)
|
|
|
+ };
|
|
|
+ foreach (var et in localEntities)
|
|
|
{
|
|
|
- ExceptionLogEvent?.Invoke(exTable, "DBServiceImpl.StartDbService.InitTables", null, LogEnum.DbException);
|
|
|
+ try { Db.CodeFirst.InitTables(et); }
|
|
|
+ catch (Exception exTable)
|
|
|
+ {
|
|
|
+ ExceptionLogEvent?.Invoke(exTable, "DBServiceImpl.StartDbService.InitTables:" + et.Name, null, LogEnum.DbException);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return true;
|