# TMS V2 Minimal Refactor Plan แนวทางนี้ยึดหลักไม่รื้อโครงสร้างเดิมของโปรเจกต์ ## สิ่งที่คงไว้ - Next.js App Router เดิม - Drizzle ORM เดิม - PostgreSQL เดิม - NextAuth เดิม - `/dashboard/*` routes เดิม - `src/features/*` structure เดิม - ตารางเดิมทั้งหมด ## สิ่งที่แก้เพิ่ม ### schema.ts - `users.password_hash` เปลี่ยนเป็น nullable เพื่อรองรับ LDAP - เพิ่ม `training_category` enum - เพิ่ม `notification_type` enum - เพิ่ม `announcement_status` enum - เพิ่ม `import_status` enum - เพิ่ม field ใน `courses` - `course_code` - `certificate_required` - `training_cost` - เพิ่ม field ใน `training_records` - `approved_hours` - `category` - `reject_reason` - เพิ่ม `pending_master_review` ให้ master ที่เกี่ยวข้อง - เพิ่มตารางใหม่ - `training_policies` - `notifications` - `announcements` - `audit_logs` - `import_jobs` ## Navigation แก้ `src/config/nav-config.ts` ให้เป็นเมนูตาม MVP Phase 1 และซ่อน Training Matrix เป็น Phase 2 ## Routes ใหม่ - `/dashboard/pending-review` - `/dashboard/training-policy` - `/dashboard/import-employees` - `/dashboard/master-review` - `/dashboard/announcements` - `/dashboard/audit-logs` ## ขั้นตอนสร้าง Migration รันคำสั่งจาก root project: ```bash npm run gen npm run migrate ``` หรือถ้าใช้ bun: ```bash bun run gen bun run migrate ``` ## หมายเหตุ ยังไม่ได้ Implement business logic ของแต่ละ module ในรอบนี้ เป็นการปรับโครงสร้างฐานข้อมูลและ route/menu เพื่อรองรับ Sprint ถัดไป