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
|
|
@ -41,4 +41,5 @@ USER nextjs
|
|||
EXPOSE 3000
|
||||
# DATABASE_URL ฉีดตอนรันผ่าน env ของ container (อย่าฝังใน image)
|
||||
# migrate สร้าง database ถ้ายังไม่มี + apply ไฟล์ที่ยังไม่ได้ apply (idempotent)
|
||||
CMD ["sh", "-c", "node scripts/migrate.mjs && exec node server.js"]
|
||||
# seed-samples sync ตาราง files กับ public/samples/ ที่ bake อยู่ใน image (idempotent)
|
||||
CMD ["sh", "-c", "node scripts/migrate.mjs && node scripts/seed-samples.mjs && exec node server.js"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue