How we can do migrations in Django?

In This blog, we are going to learn, How we can do migrations in Django?How we can do migrations in Django?

What are Migrations?

Migration is a way of applying changes that we have made to a model, into the database schema. Django creates a migration file inside the migration folder for each model to create the table schema, and each table is mapped to the model of which migration is created.

To manage database schema changes migrations are a great way. You will find Django has created migration files inside the migration folder for each model. Each table is mapped to the model.

The Commands

There are several commands which you will use to interact with migrations. After creating models you can use these commands.

makemigrations – This command is used to create a migration file that contains code for the tabled schema of a model. use the below command and it will create a migration file inside the migration folder.

for example 
$ python manage.py makemigrations

migrate – This command creates a table according to the schema defined in the migration file.

for example 
$ python manage.py migrate

sqlmigrate – This command is used to show a raw SQL query of the applied migration.

showmigrations – This command list all the migrations and their status.

Thanks for reading and supporting this blog.

How we can do migrations in Django?expoundsofttechsolution

How we can do migrations in Django?

What is GMT?