From the course: Learning Django

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Django migrations

Django migrations

From the course: Learning Django

Start my 1-month free trial

Django migrations

- [Instructor] While the Django models define the expected structure of our database, migrations are responsible for creating the necessary scripts to change this structure through time as we update our code to change our models. There are several cases in which a migration is needed. When a new model is created, a migration creates the corresponding database table. Migrations are also needed when a field is added or removed from an existing model, or, when attributes of a field have changed. All of these changes to a model's file need a corresponding change to the database, and for these purposes migrations need to be created, and then run. The first migration created for a new Django app will create tables for the models that are defined. These migrations are called initial migrations. We've defined models for our app, but we have yet to create these initial migrations and we'll tackle this in a moment. The commands…

Contents