DEV Community

Cover image for Django: makemigrations and migrate
Banji
Banji

Posted on

2 3

Django: makemigrations and migrate

In this post, I'm trying to explain what makemigrations and migrate commands can do in Django.

We have these 2 commands in Django to create SQL commands:

Alt Text

Now let's see what exactly they are doing with our database.

  1. First we create a new model class in models.py

Alt Text

Then in command-line:
Alt Text

makemigrate: What will happen after this command?
It will generate the SQL command to create the table corresponding to each class you made in the models.py file.

The corresponding SQL command after creating your class models in models.py and using makemigrations will be

Alt Text

and finally, we run this command:
Alt Text
migrate: What will happen after this command?
It will create the table in the database using the commands which have been generated by makemigrations.

API Trace View

How I Cut 22.3 Seconds Off an API Call with Sentry

Struggling with slow API calls? Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (2)

Collapse
 
amirdarx profile image
amir

good job bro

Collapse
 
banji220 profile image
Banji

Homie G

Billboard image

Try REST API Generation for MS SQL Server.

DevOps for Private APIs. With DreamFactory API Generation, you get:

  • Auto-generated live APIs mapped from database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay