Database migrations (การเปลี่ยนแปลง schema) เป็นหนึ่งในส่วนที่ยุ่งยากที่สุดของ CI/CD — ต่างจากโค้ดแอปพลิเคชันที่ stateless database เก็บ state ที่ไม่สามารถแทนที่หรือ rollback ได้ง่าย ๆ การจัดการ migration อย่างระมัดระวัง (automation, backward compatibility, safe pattern) จำเป็นต่อการ deploy ที่น่าเชื่อถือ
ทำไม database migrations จึงยาก
App code is stateless (replace it, roll back freely). DATABASES hold STATE:
→ can't just "roll back" a migration that dropped a column or transformed data
(the data may be gone) → rollbacks are risky/impossible for destructive changes
→ during deployment, OLD and NEW app code may run SIMULTANEOUSLY (rolling deploy) —
both must work with the database schema at that moment
→ Schema changes need careful coordination with code deployment.
