14 Jun 2020

Django Migrations

  • django
  • concepts
  • python
  • reference

    Django is designed to work with a relational database managed in MySQL, SQLite. A relational database organizes data in table composed of a fixed numbe of cols and infinite number of rows. Each column has a specific data type. A database schema describes these tables with their columns and datatypes. Instead of working directly with SQL, Django provides an object-relational mapper which maps the relational database to the wrld of OOP. You write Django models in python that define database fields that correspond to the cols in their database tables. When you update your models, migrations in teh app update the database tables. With django Migrations, you can easily keep multiple instances of databases in sync with your models.

    makemigrations create individual migration files based on the changes in models migrate apply and unapply those migrations made to database sqlmigrate displays the SQL statements for a migration showmigrations lists a project’s migrations and their status

    models.py

    migrate.py