Migrations เบื้องต้น
Django Migrations คืออะไร
Section titled “Django Migrations คืออะไร”Django Migrations เป็นระบบจัดการการเปลี่ยนแปลง database schema โดยติดตาม changes ใน models และสร้าง migration files ที่สามารถ apply/revert ได้ เปรียบเสมือน version control สำหรับ database
ทำไมใช้ Migrations
Section titled “ทำไมใช้ Migrations”| Reason | Description |
|---|---|
| Version Control | ติดตามประวัติการเปลี่ยนแปลง schema |
| Team Collaboration | ทุกคนได้ schema เหมือนกัน |
| Reversible | ย้อนกลับได้ถ้าผิดพลาด |
| Database Agnostic | ใช้กับ database อะไรก็ได้ |
| Automation | ไม่ต้องเขียน SQL เอง |
Migration Workflow
Section titled “Migration Workflow”graph LR A[Edit models.py] --> B[makemigrations] B --> C[Review migration file] C --> D[migrate] D --> E[Database updated]เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม
ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด
Login with Google