[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:
pqhuy1987
2026-05-04 13:02:22 +07:00
parent 3c4931687a
commit d206e14550
4 changed files with 11 additions and 9 deletions

View File

@ -17,7 +17,7 @@ Skill này là tài liệu chuyên biệt để Claude (và developer khác) dù
| Skill | Mục đích | Trigger ví dụ | Trạng thái | | Skill | Mục đích | Trigger ví dụ | Trạng thái |
|---|---|---|---| |---|---|---|---|
| `dependency-audit-erp` | Scan CVE NuGet + npm 2 FE, respect pin constraint (MediatR 12.4.1, Swashbuckle 6.9.0) | "npm audit", "dotnet vulnerable", "deps scan", "nâng cấp package" | ✅ New Tier 3 | | `dependency-audit-erp` | Scan CVE NuGet + npm 2 FE, respect pin constraint (MediatR 12.4.1, Swashbuckle 6.9.0) | "npm audit", "dotnet vulnerable", "deps scan", "nâng cấp package" | ✅ New Tier 3 |
| `ef-core-migration` | Tạo/revert EF Core 10 migration, 3-file rule, DesignTimeDbContextFactory, **13 migration history** (+ Phase 7 pending) | "thêm migration", "EF migration", "schema update", "snapshot lỗi" | ✅ Updated Phase 6 iter 2 | | `ef-core-migration` | Tạo/revert EF Core 10 migration, 3-file rule, DesignTimeDbContextFactory, **16 migration history** (Init → AddTwoStageDeptApprovalAndSmartReject) | "thêm migration", "EF migration", "schema update", "snapshot lỗi" | ✅ Updated Phase 9 (Mig 16) |
| `iis-deploy-runbook` | 3 IIS site + win-acme cert + gitea-runner + LibreOffice + debug 500/502/SignalR prod + **G-084 IPv4/IPv6 hardening** | "prod 500", "IIS fail", "cert hết hạn", "restart app pool", "deploy IIS", "port hijack" | ✅ Updated (G-084) | | `iis-deploy-runbook` | 3 IIS site + win-acme cert + gitea-runner + LibreOffice + debug 500/502/SignalR prod + **G-084 IPv4/IPv6 hardening** | "prod 500", "IIS fail", "cert hết hạn", "restart app pool", "deploy IIS", "port hijack" | ✅ Updated (G-084) |
## Format chuẩn 1 skill ## Format chuẩn 1 skill
@ -87,5 +87,5 @@ when-to-use:
## Related ## Related
- `docs/CLAUDE.md` — quick rules + full stack context - `docs/CLAUDE.md` — quick rules + full stack context
- `docs/gotchas.md`32 bẫy đã gặp - `docs/gotchas.md`41 bẫy đã gặp
- `docs/changelog/migration-todos.md` — roadmap 5 phase + Tier 3 - `docs/changelog/migration-todos.md` — roadmap 5 phase + Tier 3

View File

@ -1,6 +1,6 @@
--- ---
name: ef-core-migration 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: when-to-use:
- "thêm migration" - "thêm migration"
- "EF Core 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`. > **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 | | # | 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}`** | | **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`** | | **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)** | | **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:** **Phase 7 pending:**
- `AddPePaymentTermFields` — tách `PurchaseEvaluations.PaymentTerms` JSON thành 6 column riêng - `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 ## 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/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/DbInitializer.cs` — seed + warn + migrate runtime + backfill (idempotent reconcile pattern)
- `src/Backend/SolutionErp.Infrastructure/Persistence/Configurations/` — IEntityTypeConfiguration<T> per entity - `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 ## Related
- `docs/database/database-guide.md` — conventions + migration workflow chi tiết - `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 - `docs/gotchas.md` #7, #17, #38 — migration pitfalls + Identity 4-field rename

View File

@ -75,7 +75,7 @@
┌───────────────────────┐ ┌───────────────────────┐
│ DATA TIER │ │ DATA TIER │
│ SQL Server 2022 │ │ SQL Server 2022 │
│ (dbo schema, 19 bảng)│ │ (dbo schema, 55 bảng)│
└───────────────────────┘ └───────────────────────┘
``` ```

View File

@ -484,8 +484,9 @@ COMMIT;
| **13** | **`AddPurchaseEvaluationCodeSequences`** | **PurchaseEvaluationCodeSequences (Prefix PK, atomic seq mirror ContractCodeSequences). Format MaPhieu PE/{YYYY}/{A\|B}/{Seq:D3}** | | **13** | **`AddPurchaseEvaluationCodeSequences`** | **PurchaseEvaluationCodeSequences (Prefix PK, atomic seq mirror ContractCodeSequences). Format MaPhieu PE/{YYYY}/{A\|B}/{Seq:D3}** |
| **14** | **`AddBudgets`** | **4 bảng module Ngân sách: Budgets + BudgetDetails + BudgetApprovals + BudgetChangelogs. + nullable FK index Contract.BudgetId & PurchaseEvaluation.BudgetId** | | **14** | **`AddBudgets`** | **4 bảng module Ngân sách: Budgets + BudgetDetails + BudgetApprovals + BudgetChangelogs. + nullable FK index Contract.BudgetId & PurchaseEvaluation.BudgetId** |
| **15** | **`AddPurchaseEvaluationDepartmentOpinions`** | **1 bảng `PurchaseEvaluationDepartmentOpinions` (UNIQUE PEId+Kind, max 1 row mỗi loại phòng ban per phiếu — UPDATE in-place, audit qua Changelog)** | | **15** | **`AddPurchaseEvaluationDepartmentOpinions`** | **1 bảng `PurchaseEvaluationDepartmentOpinions` (UNIQUE PEId+Kind, max 1 row mỗi loại phòng ban per phiếu — UPDATE in-place, audit qua Changelog)** |
| **16** | **`AddTwoStageDeptApprovalAndSmartReject`** | **3 bảng `Contract/PurchaseEvaluation/Budget DepartmentApprovals` (UNIQUE TargetId+Phase+Dept+Stage cho 2-stage NV/TPB approval per phòng × phase) + 4 ALTER (`Users.CanBypassReview` bit + 3 `RejectedFromPhase` int cho smart reject quay về Drafter + jump-back phase đã reject)** |
Tổng: **52 bảng** (+ `__EFMigrationsHistory` hệ thống). Tổng: **55 bảng** (+ `__EFMigrationsHistory` hệ thống).
## 8bis. Bảng mới sau Migration 9-11 ## 8bis. Bảng mới sau Migration 9-11