[CLAUDE] Docs+Skill: chốt Session 16 wrap-up — drastic refactor flat workflow (Chunk D)
Session 16 (2026-05-08) docs/skill/memory wrap-up: STATUS.md: - Last updated Session 16 (2 commit Chunk A+B) - Phase summary count (20→21 mig, 96→77 test, 57→55 bảng) - Recently Done row Session 16 chi tiết (drastic refactor hoàn tất) - Phase enum simplified semantic post-Mig 21 HANDOFF.md: - TL;DR Session 16 prepend với 2 chunk + Chunk C SKIP rationale - Per-chunk implementation chi tiết (Domain + Mig 21 + Service + Tests + FE Designer) - 8 cảnh báo Session 17+: UAT live test / old data migration / Sample seed / Budget N-stage / schema-diagram / skill refresh / tests flat / Hard blockers Ops migration-todos.md: Phase 9 + Session 16 block 2 chunk done + 7 defer task Session log NEW `2026-05-08-0500-drastic-refactor-flat-workflow.md`: - Bối cảnh resume từ S15 defer - Spec implementation (Phase enum, state machine, schema Mig 21) - Per-chunk Chunk A + Chunk B detail - Chunk C skip rationale - Memory `feedback_drastic_refactor_scope` validation: scope estimate 30% accurate (3h actual vs 10h conservative) - Plan organization sau S16 Skill ef-core-migration: - description + heading: 20→21 migration - + Mig 21 row "RefactorWorkflowToFlatModel" với detail (4 ALTER + 2 ALTER + DROP TABLE × 2 + DROP COLUMN × 2 + restore simple unique × 2) - Total 57→55 bảng (-2 InnerStep tables) - Tests: 96→77 (drop 19 legacy) CLAUDE.md root: - Migration count 20→21 - DB tables 57→55 - Workflow flat description thay N-stage description docs/rules.md §7: 96→77 test (Mig 21 simplified) Memory `project_solution_erp.md`: - Add "Tổng sau session 16" block với drastic refactor details 🎉 Session 16 wrap-up. Cumulative since session start (S15 wrap-up `38d10b7`): 4 commit (S15 wrap-up was final S15) + 3 commit Session 16 (A `dbb0089` + B `88a5be1` + D current). Defer Session 17+ priority: 1. UAT live test workflow flat (3 phòng × N cấp realistic) 2. Old PE/HĐ legacy phase data migration 3. Sample data seed (Task 2 carry-over) 4. Hard blockers Ops 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ó 20 migration sẵn (Init → AddContractWorkflowInnerStepsAndAlterDeptApprovalUnique). 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ó 21 migration sẵn (Init → RefactorWorkflowToFlatModel). 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 (20 migration hiện có)
|
||||
## Migration history (21 migration hiện có)
|
||||
|
||||
| # | Name | Tables added / changed |
|
||||
|---|---|---|
|
||||
@ -40,8 +40,9 @@ when-to-use:
|
||||
| **18** | **`AddPeWorkflowInnerStepsAndPositionLevel`** | **N-stage workflow PE — 1 CREATE TABLE `PurchaseEvaluationWorkflowStepInnerSteps` (Order, DepartmentId, PositionLevel, Name, SlaDays, IsRequired) + 2 ALTER (`Users.PositionLevel int?` 1=NV/2=PP/3=TP + `PEDeptApproval.InnerStepId Guid?`) + 3 IX + FK Cascade Step / Restrict Dept+InnerStep. Phase 9+ — Session 12 (2026-05-07).** |
|
||||
| **19** | **`AlterPeDeptApprovalsUniqueFilteredForInnerSteps`** | **Filtered unique split: drop UNIQUE cũ Mig 16 → 2 filtered: legacy `WHERE InnerStepId IS NULL` (Stage Review/Confirm) + N-stage `WHERE InnerStepId IS NOT NULL` (per inner step). Tránh conflict 2 inner step cùng dept Stage=Confirm. Session 12.** |
|
||||
| **20** | **`AddContractWorkflowInnerStepsAndAlterDeptApprovalUnique`** | **N-stage workflow Contract mirror PE Mig 18+19 — GỘP 1 migration: CREATE TABLE `WorkflowStepInnerSteps` + ALTER `ContractDeptApproval.InnerStepId` + DropIndex old + Recreate filtered legacy/N-stage + 3 IX + FK. Session 13 (2026-05-07).** |
|
||||
| **21** | **`RefactorWorkflowToFlatModel`** | **🎯 DRASTIC REFACTOR (Session 16, 2026-05-08): bỏ phase enum legacy, dùng ChoDuyet=10 đơn nhất + currentStepIndex tracking. Workflow flat (Phòng × Cấp + Approvers). 4 ALTER (PE/Contract +CurrentWorkflowStepIndex/RejectedAtStepIndex) + 2 ALTER (WorkflowStep +DepartmentId/PositionLevel PE+Contract) + DROP TABLE × 2 (PE+Contract WorkflowStepInnerSteps Mig 18+20) + DROP COLUMN InnerStepId × 2 + DROP filtered indexes Mig 19/20 + RESTORE simple unique non-filtered × 2.** |
|
||||
|
||||
Total: **57 bảng** dbo + `__EFMigrationsHistory` (Mig 17 alter cột; Mig 18 + Mig 20 thêm 1 bảng/mỗi; Mig 19 chỉ alter index). Xem `docs/database/schema-diagram.md` ERD đầy đủ.
|
||||
Total: **55 bảng** dbo + `__EFMigrationsHistory` (Mig 21 drop 2 InnerStep tables, restore Mig 16 simple unique). Xem `docs/database/schema-diagram.md` ERD đầy đủ.
|
||||
|
||||
## N-stage workflow pattern (Mig 18-20 — Session 12-13)
|
||||
|
||||
@ -71,7 +72,7 @@ Architecture decision đáng ghi cho session sau:
|
||||
|
||||
**Phase 8 update (2026-04-29 Session 5):**
|
||||
- Migration 15 `AddPurchaseEvaluationDepartmentOpinions` — 1 bảng riêng (UNIQUE PEId+Kind), max 4 row mỗi phiếu cho 4 phòng ban (Phê duyệt/Ccm/MuaHang/SmPm). UPDATE in-place khi user đổi ý, audit qua Changelog.
|
||||
- Tests Phase 1-2-3mini-2stage-Nstage live: `tests/SolutionErp.Domain.Tests/` (54 test policy state machine) + `tests/SolutionErp.Infrastructure.Tests/` (17 test code generator + 6 test PE WF versioning + 6 test PE 2-stage Session 9 + 6 PE N-stage Session 12 + 6 Contract N-stage Session 13 + 1 PE Reject Từ chối Session 14). **Total 96 test pass / ~3s**. CI fail → no deploy.
|
||||
- Tests Phase 1-2-3mini live (Mig 21 drastic refactor drop legacy 19): `tests/SolutionErp.Domain.Tests/` (54 test policy state machine) + `tests/SolutionErp.Infrastructure.Tests/` (17 test code generator + 6 test PE WF versioning). **Total 77 test pass / ~3s**. Drop 19 legacy (PE 2-stage S9 + PE N-stage S12 + Contract N-stage S13 + PE Reject S14) — Mig 21 simplify model, write new tests cho flat workflow flow khi UAT bug.
|
||||
- CI optimize 3 fix (29/04):
|
||||
- Manual checkout bypass github.com (gotcha #39) — fix TCP timeout 21s
|
||||
- Path filter docs-only skip (gotcha #41) — commit MD-only KHÔNG trigger CI
|
||||
|
||||
Reference in New Issue
Block a user