🍡 Django

Updated at 2017-02-21 00:48
  1. Create the model class to app_name/models/.
  2. Import the model class in app_name/models/ if it exists.
  3. Then use the following commands.
# creates a migration files for missing model definitions
python makemigrations app_name --name model_name_plural

# show the list of migrations
python showmigrations app_name

# show the SQL this migration would run
python sqlmigrate app_name 0666

# migrate
python migrate

# rollback to this migration
python migrate app_name 0665

# remove all migrations
python migrate app_name zero

# migrate all back
python migrate app_name