260322:1648 Correct Coresspondence / Doing RFA / Correct CI
CI Pipeline / build (push) Failing after 12m41s
Build and Deploy / deploy (push) Failing after 2m44s

This commit is contained in:
admin
2026-03-22 16:48:12 +07:00
parent e5deedb42e
commit 11984bfa29
683 changed files with 105251 additions and 29068 deletions
@@ -16,18 +16,22 @@
### 1. Schema Updates (`lcbp3-v1.7.0-schema.sql`)
#### 1.1 เพิ่ม Columns ใน `shop_drawing_revisions`
```sql
is_current BOOLEAN DEFAULT NULL COMMENT '(TRUE = Revision ปัจจุบัน, NULL = ไม่ใช่ปัจจุบัน)'
created_by INT COMMENT 'ผู้สร้าง'
updated_by INT COMMENT 'ผู้แก้ไขล่าสุด'
```
- เพิ่ม Foreign Keys สำหรับ `created_by` และ `updated_by` ไปยัง `users` table
- เพิ่ม `UNIQUE KEY uq_sd_current (shop_drawing_id, is_current)` เพื่อ enforce ว่ามี `is_current = TRUE` ได้แค่ 1 row ต่อ drawing
#### 1.2 เพิ่ม Columns ใน `asbuilt_drawing_revisions`
- เหมือนกับ `shop_drawing_revisions`
#### 1.3 เปลี่ยน Unique Constraint ของ `drawing_number`
- **เดิม:** `UNIQUE (drawing_number)` - Global uniqueness
- **ใหม่:** `UNIQUE (project_id, drawing_number)` - Project-scoped uniqueness
@@ -42,6 +46,7 @@ CREATE OR REPLACE VIEW vw_asbuilt_drawing_current AS ...
```
**ประโยชน์:**
- Query ง่ายขึ้นโดยไม่ต้อง JOIN ทุกครั้ง
- ตัวอย่าง: `SELECT * FROM vw_shop_drawing_current WHERE project_id = 3`
@@ -68,19 +73,19 @@ SET sdr.is_current = TRUE;
MariaDB/MySQL ไม่อนุญาตให้มี duplicate values ใน UNIQUE constraint รวมถึง `FALSE` หลายตัว:
| `is_current` | ความหมาย | อนุญาตหลายแถว? |
| ------------ | -------------- | ----------------------------- |
| `TRUE` | Revision ปัจจุบัน | ❌ ไม่ได้ (UNIQUE) |
| `NULL` | Revision เก่า | ✅ ได้ (NULL ignored in UNIQUE) |
| `FALSE` | Revision เก่า | ❌ ไม่ได้ (จะซ้ำกัน) |
| `is_current` | ความหมาย | อนุญาตหลายแถว? |
| ------------ | ----------------- | ------------------------------- |
| `TRUE` | Revision ปัจจุบัน | ❌ ไม่ได้ (UNIQUE) |
| `NULL` | Revision เก่า | ✅ ได้ (NULL ignored in UNIQUE) |
| `FALSE` | Revision เก่า | ❌ ไม่ได้ (จะซ้ำกัน) |
---
## 📁 ไฟล์ที่แก้ไข
| ไฟล์ | การเปลี่ยนแปลง |
| ----------------------------------------------------- | ------------------------------------ |
| `specs/07-database/lcbp3-v1.7.0-schema.sql` | เพิ่ม columns, views, และ constraints |
| ไฟล์ | การเปลี่ยนแปลง |
| ----------------------------------------------------- | ---------------------------------------- |
| `specs/07-database/lcbp3-v1.7.0-schema.sql` | เพิ่ม columns, views, และ constraints |
| `specs/07-database/lcbp3-v1.7.0-seed-shopdrawing.sql` | เพิ่ม UPDATE statement สำหรับ is_current |
---