[CLAUDE] Docs+Skill: chốt session 8 ending — patch count drift + skill refresh
Session 8 ending workflow theo template (kết thúc lúc ~13:00). Patch drift count post Migration 16: - docs/architecture.md §1: "(dbo schema, 19 bảng)" → 55 bảng (drift cũ session 6 chưa fix, giờ fix luôn) - docs/database/schema-diagram.md §8 Migration history: thêm row 16 AddTwoStageDeptApprovalAndSmartReject + Tổng 52 → 55 bảng - .claude/skills/ef-core-migration/SKILL.md: 15→16 migration history, 52→55 tables, description + code pointers + related links - .claude/skills/README.md: ef-core-migration row "13 migration" → 16, gotchas count "32 bẫy" → 41 (drift cũ chưa fix) Memory entry mới (cross-session pattern): - feedback_per_chunk_commit.md: rule per-chunk commit cho big-feature (>500 LOC, multi-layer). Bài học S8 — 5 commit A-B-C-D-E thay vì 1 monolithic. MEMORY.md index +1 entry (6 total). Skip (intentional, theo §6.5 KHÔNG cố sửa): - docs/gotchas.md: KHÔNG có gotcha mới đáng note (S8 dùng pattern đã proven, không có bug pitfall mới) - docs/database/database-guide.md: KHÔNG có migration table chi tiết, chỉ conventions. Skip. - contract-workflow + permission-matrix skills: KHÔNG touch (PE module only, contract policy chưa đổi, permission không liên quan bypass-review) Verify: - 77 unit test vẫn pass (54 Domain + 23 Infra) - Build pass Total session 8 cumulative: 6 commit (5 code A-B-C-D-E1 + 1 docs ending). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
name: ef-core-migration
|
||||
description: Tạo/sửa/revert EF Core 10 migration cho SOLUTION_ERP. Dùng khi thêm entity mới, thay đổi schema, rollback migration, debug DesignTimeDbContextFactory fail. Đã có 15 migration sẵn (Init → AddPurchaseEvaluationDepartmentOpinions). Snapshot + Designer + Migration 3-file rule bắt buộc commit đủ.
|
||||
description: Tạo/sửa/revert EF Core 10 migration cho SOLUTION_ERP. Dùng khi thêm entity mới, thay đổi schema, rollback migration, debug DesignTimeDbContextFactory fail. Đã có 16 migration sẵn (Init → AddTwoStageDeptApprovalAndSmartReject). Snapshot + Designer + Migration 3-file rule bắt buộc commit đủ.
|
||||
when-to-use:
|
||||
- "thêm migration"
|
||||
- "EF Core migration"
|
||||
@ -16,7 +16,7 @@ when-to-use:
|
||||
|
||||
> **Context:** .NET 10 + EF Core 10 + SQL Server. DbContext: `ApplicationDbContext` ở `Infrastructure/Persistence/`. Startup: `SolutionErp.Api`.
|
||||
|
||||
## Migration history (15 migration hiện có)
|
||||
## Migration history (16 migration hiện có)
|
||||
|
||||
| # | Name | Tables added / changed |
|
||||
|---|---|---|
|
||||
@ -35,8 +35,9 @@ when-to-use:
|
||||
| **13** | **`AddPurchaseEvaluationCodeSequences`** | **1 bảng `PurchaseEvaluationCodeSequences` (Prefix PK, LastSeq) — atomic sequence cho MaPhieu format `PE/{YYYY}/{A\|B}/{Seq:D3}`** |
|
||||
| **14** | **`AddBudgets`** | **4 bảng module Ngân sách: Budgets + BudgetDetails + BudgetApprovals + BudgetChangelogs. + nullable FK index `Contracts.BudgetId` & `PurchaseEvaluations.BudgetId`** |
|
||||
| **15** | **`AddPurchaseEvaluationDepartmentOpinions`** | **1 bảng `PurchaseEvaluationDepartmentOpinions` (UNIQUE PEId+Kind, max 1 row mỗi PeDepartmentKind per phiếu — Phê duyệt/Ccm/MuaHang/SmPm)** |
|
||||
| **16** | **`AddTwoStageDeptApprovalAndSmartReject`** | **3 bảng `Contract/PurchaseEvaluation/Budget DepartmentApprovals` (UNIQUE TargetId+Phase+Dept+Stage cho 2-stage NV.Review → TPB.Confirm per phòng × phase) + 4 ALTER (`Users.CanBypassReview` bit cho NV bypass + 3 `RejectedFromPhase` int cho smart reject jump-back). Phase 9 — đóng bug "NV duyệt được hết phase" anh Kiệt (FDC) báo. Logic 2-stage trong PurchaseEvaluationWorkflowService chỉ áp PE; HĐ + Budget defer.** |
|
||||
|
||||
Total: **52 bảng** dbo + `__EFMigrationsHistory`. Xem `docs/database/schema-diagram.md` ERD đầy đủ.
|
||||
Total: **55 bảng** dbo + `__EFMigrationsHistory`. Xem `docs/database/schema-diagram.md` ERD đầy đủ.
|
||||
|
||||
**Phase 7 pending:**
|
||||
- `AddPePaymentTermFields` — tách `PurchaseEvaluations.PaymentTerms` JSON thành 6 column riêng
|
||||
@ -226,7 +227,7 @@ sqlcmd -S .\SQLEXPRESS -d SolutionErp -U vrapp -P <pw> -i migrate.sql
|
||||
|
||||
## Code pointers
|
||||
|
||||
- `src/Backend/SolutionErp.Infrastructure/Persistence/ApplicationDbContext.cs` — DbSet cho 52 bảng (15 migration)
|
||||
- `src/Backend/SolutionErp.Infrastructure/Persistence/ApplicationDbContext.cs` — DbSet cho 55 bảng (16 migration)
|
||||
- `src/Backend/SolutionErp.Infrastructure/Persistence/DesignTimeDbContextFactory.cs` — EF tooling factory
|
||||
- `src/Backend/SolutionErp.Infrastructure/Persistence/DbInitializer.cs` — seed + warn + migrate runtime + backfill (idempotent reconcile pattern)
|
||||
- `src/Backend/SolutionErp.Infrastructure/Persistence/Configurations/` — IEntityTypeConfiguration<T> per entity
|
||||
@ -235,5 +236,5 @@ sqlcmd -S .\SQLEXPRESS -d SolutionErp -U vrapp -P <pw> -i migrate.sql
|
||||
## Related
|
||||
|
||||
- `docs/database/database-guide.md` — conventions + migration workflow chi tiết
|
||||
- `docs/database/schema-diagram.md` — **ERD 52 bảng** + §11 PE module + §12 Budget module + §13 PEDeptOpinions
|
||||
- `docs/database/schema-diagram.md` — **ERD 55 bảng** + §11 PE module + §12 Budget module + §13 PEDeptOpinions + §14 DepartmentApprovals (Mig 16)
|
||||
- `docs/gotchas.md` #7, #17, #38 — migration pitfalls + Identity 4-field rename
|
||||
|
||||
Reference in New Issue
Block a user