2026-08-13 15:01:32 +08:00
|
|
|
# 数据库切换与双数据库架构
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
|
|
|
> 所属模块:[架构概览](../概览.md)
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## 文档索引
|
|
|
|
|
|
|
|
|
|
| 文档 | 说明 |
|
|
|
|
|
|------|------|
|
2026-08-13 15:01:32 +08:00
|
|
|
| [DbContext 工厂](./DbContext工厂.md) | 两个数据库上下文工厂设计 |
|
|
|
|
|
| [迁移策略](./迁移策略.md) | 数据库迁移步骤 |
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
## 双数据库架构
|
2026-07-02 15:53:30 +08:00
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
```text
|
|
|
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
|
|
|
│ appsettings.json │
|
|
|
|
|
│ Database:LocalPath → local.db │
|
|
|
|
|
│ Database:ReleasePath → release.db │
|
|
|
|
|
└─────────────────────────────────────────────────────────────────┘
|
2026-07-02 15:53:30 +08:00
|
|
|
│
|
|
|
|
|
▼
|
2026-08-13 15:01:32 +08:00
|
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
|
|
|
│ DbContextFactory │
|
|
|
|
|
│ 读取配置 → 选择 Provider → 创建 WctMinerDbContext │
|
|
|
|
|
│ ReleaseDbContextFactory │
|
|
|
|
|
│ 读取配置 → 选择 Provider → 创建 ReleaseDbContext │
|
|
|
|
|
└─────────────────────────────────────────────────────────────────┘
|
2026-07-02 15:53:30 +08:00
|
|
|
│
|
|
|
|
|
▼
|
2026-08-13 15:01:32 +08:00
|
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
|
|
|
│ local.db release.db │
|
|
|
|
|
│ ──────── ────────── │
|
|
|
|
|
│ tx_panel charging_parameter │
|
|
|
|
|
│ tx_hardware 独立实体,无外键关联 │
|
|
|
|
|
│ tx_software │
|
|
|
|
|
│ rx_type │
|
|
|
|
|
│ test_scenario │
|
|
|
|
|
│ qfod_record │
|
|
|
|
|
│ ploss_record │
|
|
|
|
|
└─────────────────────────────────────────────────────────────────┘
|
2026-07-02 15:53:30 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 当前状态
|
|
|
|
|
|
|
|
|
|
| 项目 | 状态 |
|
|
|
|
|
|------|------|
|
|
|
|
|
| SQLite | ✅ 默认启用 |
|
2026-08-13 15:01:32 +08:00
|
|
|
| PostgreSQL | ✅ 架构支持 |
|
|
|
|
|
| local.db | ✅ 解析库 |
|
|
|
|
|
| release.db | ✅ 发布库 |
|
|
|
|
|
| 双库隔离 | ✅ 无外键/导航属性 |
|