- Implement tests for various scenarios including user edits, initial dirty state, and document changes. - Ensure proper flagging of uncommitted changes and silent saves for documents opened in a dirty state. - Test debounce behavior for document change notifications and version clearing functionality. - Validate suspension and resumption of auto-saving during versioning processes.
19 lines
2.1 KiB
Markdown
19 lines
2.1 KiB
Markdown
|
|
---
|
|
name: sync-db
|
|
description: Sync Drizzle schema ลง PostgreSQL container judes-note-db + seed ไฟล์ตัวอย่าง — ใช้หลังแก้ db/schema.ts หรือตอน setup ครั้งแรก
|
|
---
|
|
|
|
## ขั้นตอน
|
|
|
|
1. **สร้างไฟล์ migration:** รัน `npx drizzle-kit generate` (อ่าน config จาก `drizzle.config.ts` — เทียบ `db/schema.ts` กับไฟล์ที่มีใน `drizzle/` ไม่ต้องต่อ DB) — ถ้าไม่มีการเปลี่ยนแปลงจะขึ้น "No schema changes" แล้วจบเฉย ๆ
|
|
2. **Apply + seed:** รัน `npm run db:prepare` (= compose up + `scripts/migrate.mjs` apply ไฟล์ใหม่ + `scripts/seed-samples.mjs` sync ไฟล์จาก `public/note/samples/`) — idempotent
|
|
3. **รายงานผลแต่ละขั้นตามจริง** — ขั้นไหนไม่ได้ทำบอกสาเหตุ อย่าเดา
|
|
|
|
> ห้ามใช้ `npx drizzle-kit push` — production (docker/web.Dockerfile) apply จากไฟล์ `drizzle/*.sql` เท่านั้น ถ้า dev push schema ตรง ๆ ไฟล์ migration จะตามไม่ทันแล้วสองฝั่งเพี้ยนกัน
|
|
|
|
## ข้อควรระวัง
|
|
|
|
- `DATABASE_URL` ชี้ที่ container `judes-note-db` (postgres:17-alpine, พอร์ต 54322 — ไม่ใช่ Supabase) — ถ้า container ไม่รันอยู่ ให้สั่ง `docker start judes-note-db` หรือแจ้งผู้ใช้ตามคำสั่ง docker run ใน README
|
|
- ห้ามลบ volume `judes-note-db-data` เว้นแต่ผู้ใช้สั่งชัดเจน (มีข้อมูล annotation จริงหายได้)
|
|
- ไม่ต้องตั้ง realtime publication/replica identity อีกต่อไป (SSE sync ผ่าน `lib/annotate-events.ts` ไม่ผ่าน DB trigger)
|