Open In App
Related Articles

Django migrate command | Python

Improve Article
Save Article
Like Article

According to documentation, Migrations are Django’s way of propagating changes you make to your models (adding a field, deleting a model, etc.) into your database schema. They’re designed to be mostly automatic, but you’ll need to know when to make migrations when to run them, and the common problems you might run into.

migrate is run through the following command for a Django project.

 Python migrate 

Django python migrate command

migrate executes those SQL commands in the database file. So after executing migrate all the tables of your installed apps are created in your database file.

You can confirm this by installing SQLite browser and opening db.sqlite3 you can see all the tables appears in the database file after executing migrate command.


For example, if we make a model class-

from django.db import models
class Person(models.Model):
    first_name = models.CharField(max_length = 30)
    last_name = models.CharField(max_length = 30)

The corresponding sql command after using makemigrations will be

CREATE TABLE myapp_person (
"first_name" varchar(30) NOT NULL,
"last_name" varchar(30) NOT NULL

and using above command, table will be created in the database when we use migrate.
Migrate command is covered in next article.
and now form terminal running following command will create table for this model in your database

 Python migrate

Now if we check our database, a table with name geeks_geeksmodel is created,


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 26 Sep, 2019
Like Article
Save Article
Similar Reads
Related Tutorials