Auto-migrate ตอน container start (แทนการ push มือ)
All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 44s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 3s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 0s

- scripts/migrate.mjs: สร้าง database ถ้ายังไม่มี + apply ไฟล์
  drizzle/*.sql ที่ยังไม่อยู่ในตาราง _migrations (ทีละไฟล์ใน
  transaction, แยก statement ด้วย --> statement-breakpoint)
  — เจอ schema ที่สร้างไว้ก่อนแล้ว (42P07/42710/42701) ถือว่า applied
- web.Dockerfile: ฝัง drizzle/ + scripts/ ใน image,
  CMD รัน migrate ก่อน node server.js
- .dockerignore: เอา drizzle ออก (ต้องขึ้น image)
- commit ไฟล์ migration แรก drizzle/0000 (จาก drizzle-kit generate)

ทดสอบบน PostgreSQL 17 แล้ว 3 เคส: สร้างใหม่ / รันซ้ำ / schema
มีอยู่ก่อนแบบไม่มี _migrations (เคส server ปัจจุบัน) — ผ่านทั้งหมด

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-09-10 16:25:14 +07:00
parent f6f4ed9129
commit 60658568f7
6 changed files with 621 additions and 2 deletions

View file

@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1789031603082,
"tag": "0000_narrow_quentin_quire",
"breakpoints": true
}
]
}