From d206e145501074a4e03cfa46ddad8dc168ecf516 Mon Sep 17 00:00:00 2001 From: pqhuy1987 Date: Mon, 4 May 2026 13:02:22 +0700 Subject: [PATCH] =?UTF-8?q?[CLAUDE]=20Docs+Skill:=20ch=E1=BB=91t=20session?= =?UTF-8?q?=208=20ending=20=E2=80=94=20patch=20count=20drift=20+=20skill?= =?UTF-8?q?=20refresh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .claude/skills/README.md | 4 ++-- .claude/skills/ef-core-migration/SKILL.md | 11 ++++++----- docs/architecture.md | 2 +- docs/database/schema-diagram.md | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.claude/skills/README.md b/.claude/skills/README.md index eac3e7a..ffa74e1 100644 --- a/.claude/skills/README.md +++ b/.claude/skills/README.md @@ -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 | |---|---|---|---| | `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) | ## Format chuẩn 1 skill @@ -87,5 +87,5 @@ when-to-use: ## Related - `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 diff --git a/.claude/skills/ef-core-migration/SKILL.md b/.claude/skills/ef-core-migration/SKILL.md index 5018679..9b98765 100644 --- a/.claude/skills/ef-core-migration/SKILL.md +++ b/.claude/skills/ef-core-migration/SKILL.md @@ -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 -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 per entity @@ -235,5 +236,5 @@ sqlcmd -S .\SQLEXPRESS -d SolutionErp -U vrapp -P -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 diff --git a/docs/architecture.md b/docs/architecture.md index b66dbdb..eafa903 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -75,7 +75,7 @@ ┌───────────────────────┐ │ DATA TIER │ │ SQL Server 2022 │ - │ (dbo schema, 19 bảng)│ + │ (dbo schema, 55 bảng)│ └───────────────────────┘ ``` diff --git a/docs/database/schema-diagram.md b/docs/database/schema-diagram.md index c4c0ef3..d9f64b1 100644 --- a/docs/database/schema-diagram.md +++ b/docs/database/schema-diagram.md @@ -484,8 +484,9 @@ COMMIT; | **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** | | **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