Seed ไฟล์ตัวอย่างแบบ idempotent sync กับ public/samples/
- scripts/seed-samples.mjs: INSERT ไฟล์ที่ยังไม่มี row + DELETE row ที่ไฟล์หาย (CASCADE ลบ annotation ตาม) — แทน SQL seed มือเดิมใน README - รันอัตโนมัติตอน container start ต่อจาก migrate + npm run seed-samples บนเครื่อง dev - สลับไฟล์ sample เป็นคำสั่งศาล 2 ฉบับ Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
parent
ec26d79f0e
commit
79c9e2cc41
7 changed files with 47 additions and 3 deletions
|
|
@ -59,12 +59,14 @@ npx drizzle-kit push
|
|||
|
||||
### 5. Seed ไฟล์ตัวอย่าง
|
||||
|
||||
ไฟล์ตัวอย่างอยู่ที่ `public/samples/` แล้ว — ลงทะเบียนในตาราง `files` (รันเฉพาะเมื่อตารางว่าง ไม่งั้นข้อมูลจะซ้ำ):
|
||||
ไฟล์ตัวอย่างอยู่ที่ `public/samples/` แล้ว — sync ลงตาราง `files` (idempotent รันซ้ำได้):
|
||||
|
||||
```bash
|
||||
docker exec judes-note-db psql -U postgres -c "insert into files (title, pdf_url) values ('01012-672427-4f-690609-0000840227.pdf','/samples/01012-672427-4f-690609-0000840227.pdf'), ('01012-672427-1f-690609-0000840223.pdf','/samples/01012-672427-1f-690609-0000840223.pdf'), ('dashboard-report-2026-09-03.pdf','/samples/dashboard-report-2026-09-03.pdf');"
|
||||
npm run seed-samples
|
||||
```
|
||||
|
||||
> บน production ไม่ต้องรันมือ — script เดียวกัน (`scripts/seed-samples.mjs`) รันอัตโนมัติตอน container start ต่อจาก migration ไฟล์ที่หายจาก `public/samples/` จะถูกลบ row พร้อม annotation ที่ผูกอยู่ (CASCADE)
|
||||
|
||||
### 6. รัน dev server
|
||||
|
||||
```bash
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue