makemigrations مقابل migrate
كيف يخطط Django لتغييرات المخطط ويطبّقها
makemigrations مقابل migrate درس مجاني في Django Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Django Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Django Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Two Steps, Not One
Django changes your database in two steps: first it writes a plan, then it runs that plan. Knowing which is which saves a lot of confusion. 🧭
makemigrations Plans
makemigrations looks at your models, spots what changed, and writes a migration file describing the change. It does not touch the database yet.
python manage.py makemigrationsmigrate Applies
migrate takes those migration files and actually runs them against the database, creating or altering real tables.
python manage.py migrateWhy Split Them
Splitting plan from action lets you review a change, commit it to git, and apply the exact same steps on every machine and server.
Migrations Are Files
Each plan lives as a file in your app under migrations/. You commit these files so teammates apply identical changes.
A Typical Cycle
Edit a model, run makemigrations to record it, then run migrate to apply it. That loop is your everyday schema workflow.
Naming Migrations
Add a clear label so files read like a history, not a pile of numbers. Use the --name flag to describe what changed.
python manage.py makemigrations --name add_published_fieldTargeting One App
Pass an app label to generate or apply migrations for just that app, keeping unrelated changes out of the way.
python manage.py makemigrations blogCheck Without Changing
Run makemigrations with --check in CI to fail the build if a model change has no matching migration yet.
python manage.py makemigrations --check --dry-runSee What Is Applied
The showmigrations command lists every migration and marks the applied ones with an X, so you know your exact state.
python manage.py showmigrationsOrder Matters
Always makemigrations first, then migrate. Running migrate alone applies whatever plans already exist, including Django built-ins.
Quick Check
Which command actually changes the database tables?
Recap
You learned the rhythm: makemigrations writes the plan, migrate applies it. Plan first, apply second, and your schema stays in sync everywhere. 🎉
الأسئلة الشائعة
هل درس «makemigrations مقابل migrate» مجاني؟
نعم — نص درس «makemigrations مقابل migrate» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Django Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Django Academy 4 دروس في المجموع.
ماذا ستتعلم في «makemigrations مقابل migrate»؟
كيف يخطط Django لتغييرات المخطط ويطبّقها تتمرن على Django Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Django Academy؟
لا تُشترط خبرة سابقة. Django Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «makemigrations مقابل migrate»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Django Academy هذا؟
نعم. كل درس في Django Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- makemigrations مقابل migrate
- قراءة ملف Migration
- تغيير Model وإعادة إجراء Migration
- sqlmigrate وفحص SQL