690414:1113 Update README.md /.agents/skills, /.windsurf/workflows
This commit is contained in:
@@ -1371,6 +1371,7 @@ erDiagram
|
||||
| expires_at | DATETIME | NULL | เวลาหมดอายุของไฟล์ Temp (เพื่อให้ Cron Job ลบออก) |
|
||||
| checksum | VARCHAR(64) | NULL | SHA-256 Checksum สำหรับ Verify File Integrity [Req 3.9.3] |
|
||||
| reference_date | DATE | NULL | Date used for folder structure (e.g. Issue Date) to prevent broken paths |
|
||||
| workflow_history_id | VARCHAR(36) | NULL, FK | **[ADR-021]** อ้างอิง workflow_histories.publicId — NULL = ไฟล์แนบหลักของเอกสาร; NOT NULL = ไฟล์หลักฐานประจำ Workflow Step |
|
||||
|
||||
**Indexes**:
|
||||
|
||||
@@ -1382,10 +1383,11 @@ erDiagram
|
||||
- UNIQUE INDEX idx_attachments_uuid (uuid)
|
||||
- INDEX (created_at)
|
||||
- INDEX (reference_date)
|
||||
- INDEX (workflow_history_id)
|
||||
|
||||
**Relationships**:
|
||||
|
||||
- Parent: users
|
||||
- Parent: users, workflow_histories (via workflow_history_id)
|
||||
- Referenced by: correspondence_revision_attachments, circulation_attachments, shop_drawing_revision_attachments, contract_drawing_attachments
|
||||
|
||||
**Business Rules**:
|
||||
@@ -1395,6 +1397,10 @@ erDiagram
|
||||
- File path points to QNAP NAS storage
|
||||
- Original filename preserved for download
|
||||
- One file record can be linked to multiple documents
|
||||
- **[ADR-021]** `workflow_history_id = NULL` → Main Document attachment (linked via junction tables)
|
||||
- **[ADR-021]** `workflow_history_id IS NOT NULL` → Step-evidence attachment — linked exclusively to a single workflow transition history record (Approve/Reject/Return evidence)
|
||||
- Step-evidence attachments are committed (is_temporary = false) during `processTransition()` in the same transaction as the history record
|
||||
- Cleanup jobs MUST NOT delete attachments where `workflow_history_id IS NOT NULL`
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
-- ============================================================
|
||||
-- Delta 04: ADR-021 — Step-specific Attachments
|
||||
-- เพิ่ม FK workflow_history_id ใน attachments table
|
||||
-- ============================================================
|
||||
-- ข้อควรระวัง: ค่า NULL = ไฟล์แนบหลัก (Main Document)
|
||||
-- ค่าไม่ NULL = ไฟล์ประจำ Workflow Step นั้น
|
||||
|
||||
ALTER TABLE attachments
|
||||
ADD COLUMN workflow_history_id CHAR(36) NULL
|
||||
COMMENT 'FK to workflow_histories.id สำหรับไฟล์แนบประจำ Step (ADR-021). NULL = ไฟล์แนบหลัก',
|
||||
ADD CONSTRAINT fk_attachments_workflow_history
|
||||
FOREIGN KEY (workflow_history_id)
|
||||
REFERENCES workflow_histories (id)
|
||||
ON DELETE SET NULL
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
-- Index สำหรับ optimize การดึงไฟล์แนบตาม Step + เรียงตามวันที่
|
||||
CREATE INDEX idx_att_wfhist_created
|
||||
ON attachments (workflow_history_id, created_at);
|
||||
|
||||
-- ============================================================
|
||||
-- Rollback:
|
||||
-- ALTER TABLE attachments DROP FOREIGN KEY fk_attachments_workflow_history;
|
||||
-- ALTER TABLE attachments DROP COLUMN workflow_history_id;
|
||||
-- ============================================================
|
||||
@@ -0,0 +1,13 @@
|
||||
-- Delta 05: Add deadline_date to circulations (v1.8.7 — EC-CIRC-003)
|
||||
-- Purpose: เพิ่มคอลัมน์ deadline_date ที่ตาราง circulations
|
||||
-- เพื่อรองรับ EC-CIRC-003 (Overdue Badge) และการตั้งค่ากำหนดเวลา
|
||||
-- Applied: เพิ่มทีหลัง Schema v1.8.0
|
||||
-- Author: NAP-DMS v1.8.7
|
||||
|
||||
ALTER TABLE circulations
|
||||
ADD COLUMN deadline_date DATE NULL
|
||||
COMMENT 'วันครบกำหนดส่งงาน (nullable — ถ้า NULL = ไม่มีกำหนด)'
|
||||
AFTER closed_at;
|
||||
|
||||
-- Index สำหรับ query Overdue Circulations ที่ Dashboard
|
||||
CREATE INDEX idx_circulations_deadline ON circulations (deadline_date);
|
||||
@@ -781,6 +781,7 @@ CREATE TABLE circulations (
|
||||
created_by_user_id INT NOT NULL COMMENT 'ID ของผู้สร้างใบเวียน',
|
||||
submitted_at TIMESTAMP NULL COMMENT 'วันที่ส่งใบเวียน',
|
||||
closed_at TIMESTAMP NULL COMMENT 'วันที่ปิดใบเวียน',
|
||||
deadline_date DATE NULL COMMENT 'วันที่กำหนดส่งมอบ',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'วันที่สร้าง',
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'วันที่แก้ไขล่าสุด',
|
||||
FOREIGN KEY (correspondence_id) REFERENCES correspondences (id),
|
||||
@@ -868,9 +869,13 @@ CREATE TABLE attachments (
|
||||
expires_at DATETIME NULL COMMENT 'เวลาหมดอายุของไฟล์ Temp',
|
||||
CHECKSUM VARCHAR(64) NULL COMMENT 'SHA-256 Checksum',
|
||||
reference_date DATE NULL COMMENT 'Date used for folder structure (e.g. Issue Date) to prevent broken paths',
|
||||
workflow_history_id CHAR(36) NULL COMMENT 'FK to workflow_histories.id for step-specific attachments (ADR-021). NULL = main document',
|
||||
FOREIGN KEY (uploaded_by_user_id) REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
INDEX idx_attachments_reference_date (reference_date),
|
||||
UNIQUE INDEX idx_attachments_uuid (uuid)
|
||||
FOREIGN KEY (workflow_history_id) REFERENCES workflow_histories (id) ON DELETE
|
||||
SET NULL ON UPDATE CASCADE,
|
||||
INDEX idx_attachments_reference_date (reference_date),
|
||||
INDEX idx_att_wfhist_created (workflow_history_id, created_at),
|
||||
UNIQUE INDEX idx_attachments_uuid (uuid)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'ตาราง "กลาง" เก็บไฟล์แนบทั้งหมดของระบบ';
|
||||
|
||||
-- ตารางเชื่อม correspondence_revisions กับ attachments (M:N)
|
||||
|
||||
@@ -49,6 +49,9 @@ CREATE INDEX idx_tags_name ON tags (tag_name);
|
||||
|
||||
CREATE INDEX idx_tags_created_at ON tags (created_at);
|
||||
|
||||
-- Index for circulations deadline_date (EC-CIRC-003 Overdue Badge)
|
||||
CREATE INDEX idx_circulations_deadline ON circulations (deadline_date);
|
||||
|
||||
-- Indexes for correspondence_tags
|
||||
CREATE INDEX idx_correspondence_tags_correspondence ON correspondence_tags (correspondence_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user