Technical Documentation Site

Version 0.9.0

Technical Cheat Sheets

Django

database migrations

https://docs.djangoproject.com/en/3.1/topics/migrations/

You should think of migrations as a version control system for your database schema. makemigrations is responsible for packaging up your model changes into individual migration files - analogous to commits - and migrate is responsible for applying those to your database.

makemigrations: create new migrations based on the changes you have made to your models

example project name: polls

cd into the folder that contains manage.py

This command creates a migration file under migrations. The file name starts with a migration serial number.

    python manage.py makemigrations polls
migrate: apply and unapply migrations

apply the migrations created in previous step

    python manage.py migrate polls 
show migrations
    python manage.py showmigrations polls 
Last updated on 12 Jan 2021
Published on 12 Jan 2021
Edit on GitHub