[CLAUDE] Docs: S113 closeout — Supplier import v2 SHIP prod (Run #497) + Mig 64/477 test/gotcha #80

- STATUS/HANDOFF: S113 mega-line + state (Mig 63->64, test 458->477, gotcha 79->80, prod 22->37 NCC, bundle acprMqfB/Ck3BTDdA Run #497)
- gotcha #80: ! null-forgiving tren external-parsed data -> NRE an (build 0/0 khong bat; chi test-before-critical bat)
- ef-core skill: Mig 64 row + pointer-flush (session-start H1 drift, kill recurring latest-Mig class)
- session log 2026-07-12-S113-supplier-import-v2.md

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-07-12 19:24:49 +07:00
parent 0efc22364b
commit ccdcbe79f0
6 changed files with 71 additions and 11 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 |
|---|---|---|---|
| `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, migration history (mới nhất Mig 62; số → `docs/STATUS.md`) | "thêm migration", "EF migration", "schema update", "snapshot lỗi" | ✅ Updated S104 (Mig 62 ExpandSupplierFields Supplier 9→27 field; prev S98 Mig 60/61; số → `docs/STATUS.md`) |
| `ef-core-migration` | Tạo/revert EF Core 10 migration, 3-file rule, DesignTimeDbContextFactory, migration history (mới nhất → row cuối bảng skill; số → `docs/STATUS.md`) | "thêm migration", "EF migration", "schema update", "snapshot lỗi" | ✅ Updated S113 (mig-ref → pointer anti-drift B1; Mig 63 AddSupplierImportSourceFields row added; số → `docs/STATUS.md`) |
| `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

View File

@ -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ó nhiều migration (số hiện tại → docs/STATUS.md canonical; mới nhất Mig 62 ExpandSupplierFields, S104). 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ó nhiều migration (số hiện tại + mới nhất → docs/STATUS.md canonical + row cuối bảng history trong skill này — KHÔNG hardcode số ở đây, B1 anti-drift). 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 (số hiện tại → `docs/STATUS.md` canonical; mới nhất Mig 62)
## Migration history (số hiện tại → `docs/STATUS.md` canonical; mới nhất = row cuối bảng)
| # | Name | Tables added / changed |
|---|---|---|
@ -82,8 +82,10 @@ when-to-use:
| **60** | **`AddPeEndedByLevelFinalize`** | **🎯 S97 PE +`EndedByLevelFinalize bit NOT NULL DEFAULT 0` cờ RUNTIME "phiếu ĐÃ kết thúc sớm bằng level-finalize" (set-true CHỈ nhánh finalize trong service); display `EndsBeforeCeo` cho phiếu DaDuyet đọc RUNTIME thay suy-CONFIG (gotcha #78 phiếu opt-out lên CEO hết báo sai "không qua CEO"). Kèm `Sql()` backfill marker soi NHẦM bảng `Approvals` match 0 (xem Mig 61). 1 AddColumn, no new table.** |
| **61** | **`BackfillEndedByLevelFinalizeFromChangelog`** | **🎯 S97 DATA-ONLY no-schema (đính chính Mig 60): backfill query ĐÚNG bảng `PurchaseEvaluationChangelogs.ContextNote LIKE N'%Duyệt KẾT THÚC tại%'` + PhaseAtChange=7. PE 2 bảng lịch-sử TÁCH VAI: `Approvals` = per-approver record vs `Changelogs.ContextNote` = transition+marker (`LogTransitionAsync`). Idempotent, SQL-Server-only, prod-verified A/005/A/008 flag 01 + A/010 control unchanged (gotcha #79 xác định đúng bảng-writer + verify marker-count prod TRƯỚC khi tin backfill; backfill=0-rows = cờ đỏ).** |
| **62** | **`ExpandSupplierFields`** | **🎯 S104 Supplier 927 field (Phase A của 30-col NCC Excel import, anh Kiệt FDC): 18 AddColumn nullable + 18 DropColumn Down + `SupplierType +CaHai=6` append-only + enum `SupplierStatus` mới + guarded un-cram `Sql()` (clear legacy crammed Note 4 seeded rows exact-match, reversible). **No new table (89 giữ — 18 AddColumn/0 CreateTable)**. Seed fill-nulls-if-exists 30-field TRUONGGIANG/TANPHU/TGN/DONGDUONG idempotent. Commit `778fc98` shipped UN-closed-out S104 docs-reconcile; prod-verified Run #488 PASS; 440 test #65-no-bite đổi chữ Create/UpdateSupplierCommand. Phase B (Excel-auto-map) defer.** |
| **63** | **`AddSupplierImportSourceFields`** | **🎯 S112 Supplier +`SourceUpdatedAt datetime2?` + `SourceUpdatedBy nvarchar(200)?` (import-provenance cột 29/30 file Excel "Database NCC" Phase B Excel-import Phase B). 2 AddColumn nullable + 2 DropColumn Down (reversible). **No new table (89 giữ)**. Prod-verified Run #496 PASS `__EFMigrationsHistory` top + 2/2-col present; commit `e100ef0`.** |
| **64** | **`AddSupplierPublishState`** | **🎯 S113 Supplier +`IsPublic` bit NOT NULL default 0 (cổng công-bố "thiếu NCC nháp/ẩn" R4): AddColumn + `Sql("UPDATE Suppliers SET IsPublic=1")` backfill 37/37 prodpublic + DropIndexCreateIndex đổi Code filtered-unique `WHERE [IsDeleted]=0 AND [Code]<>''` (cho phép nhiều nháp Code=''). **No new table (89 giữ)**. Reversible Down (⚠ edge: rollback sau khi 2 nháp Code='' sẽ kẹt CreateIndex filter ). Prod-verified Run #497; commit `5fa11b5`. Kèm gotcha #80 (null-Code NRE NewSupplier).** |
Total: **89 bảng** `sys.tables` (= 88 dbo-app + `__EFMigrationsHistory`; re-ground S97 cicd Run #482 LIVE số canonical `docs/STATUS.md`; last schema-changing Mig 50 net 9388-app, Mig 51-62 đều AddColumn/index/data-only/schema-expand không đổi số bảng). Xem `docs/database/schema-diagram.md` migration table + §11-15 module ERD 16+ Mig 27-62 chi tiết pending).
Total: **89 bảng** `sys.tables` (= 88 dbo-app + `__EFMigrationsHistory`; re-ground S97 cicd Run #482 LIVE số canonical `docs/STATUS.md`; last schema-changing Mig 50 net 9388-app, Mig 51-64 đều AddColumn/index/data-only/schema-expand không đổi số bảng). Xem `docs/database/schema-diagram.md` migration table + §11-15 module ERD 16+ Mig 27-64 chi tiết pending).
## N-stage workflow pattern (Mig 18-20 — Session 12-13)