makemigrationsとmigrateの違い
Djangoがスキーマ変更を計画し適用する仕組みを学びます
「makemigrationsとmigrateの違い」はCoddyKit上の無料Django Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これは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時間対応のAIチューター)、Django Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Django Academyコースには全4レッスンが含まれています。
「makemigrationsとmigrateの違い」で何を学びますか?
Djangoがスキーマ変更を計画し適用する仕組みを学びます ブラウザで直接実行するハンズオンコードでDjango Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Django Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのDjango Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。
「makemigrationsとmigrateの違い」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このDjango Academyレッスンでコードを書いて実行できますか?
はい。すべてのDjango Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- makemigrationsとmigrateの違い
- マイグレーションファイルを読む
- モデルを変更して再度マイグレーションする
- sqlmigrateでSQLを調べる