docs: 更新项目架构与数据模型文档
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# 数据库切换支持
|
||||
# 数据库切换与双数据库架构
|
||||
|
||||
> 所属模块:[架构概览](../概览.md)
|
||||
|
||||
@@ -8,38 +8,48 @@
|
||||
|
||||
| 文档 | 说明 |
|
||||
|------|------|
|
||||
| [DbContext 工厂](./DbContext工厂.md) | 数据库上下文工厂设计 |
|
||||
| [迁移策略](./迁移策略.md) | 数据库迁移和切换步骤 |
|
||||
| [DbContext 工厂](./DbContext工厂.md) | 两个数据库上下文工厂设计 |
|
||||
| [迁移策略](./迁移策略.md) | 数据库迁移步骤 |
|
||||
|
||||
---
|
||||
|
||||
## 切换策略概览
|
||||
## 双数据库架构
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ appsettings.json │
|
||||
│ "Database": { "Type": "sqlite" | "postgresql" } │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```text
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ appsettings.json │
|
||||
│ Database:LocalPath → local.db │
|
||||
│ Database:ReleasePath → release.db │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ DbContextFactory │
|
||||
│ 读取配置 → 选择 Provider → 创建 DbContext │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ DbContextFactory │
|
||||
│ 读取配置 → 选择 Provider → 创建 WctMinerDbContext │
|
||||
│ ReleaseDbContextFactory │
|
||||
│ 读取配置 → 选择 Provider → 创建 ReleaseDbContext │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ WctMinerDbContext │
|
||||
│ 统一的 DbModel 配置,适配两种数据库 │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ local.db release.db │
|
||||
│ ──────── ────────── │
|
||||
│ tx_panel charging_parameter │
|
||||
│ tx_hardware 独立实体,无外键关联 │
|
||||
│ tx_software │
|
||||
│ rx_type │
|
||||
│ test_scenario │
|
||||
│ qfod_record │
|
||||
│ ploss_record │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 当前状态
|
||||
|
||||
| 项目 | 状态 |
|
||||
|------|------|
|
||||
| SQLite | ✅ 默认启用 |
|
||||
| PostgreSQL | ✅ 架构支持,待配置 |
|
||||
| 切换方式 | 配置文件切换 |
|
||||
| PostgreSQL | ✅ 架构支持 |
|
||||
| local.db | ✅ 解析库 |
|
||||
| release.db | ✅ 发布库 |
|
||||
| 双库隔离 | ✅ 无外键/导航属性 |
|
||||
Reference in New Issue
Block a user