# Prepare migration using the latest model definitions
python manage.py makemigrations [app_name]
# Apply migrations for specified app using specified database connection (in settings.py)
python manage.py migrate [app_name] --database [database_name]
#record latest model before migration
python3 manage.py makemigrations [app_name]
#migrate to database
python3 manage.py migrate
# configure your database first before migrating default database will be sqlite3
python manage.py makemigrations
python manage.py migrate --fake
python manage.py migrate your_app zero
$ manage.py migrate --fake <appname> zero
$ rm -rf migrations
$ manage.py makemigrations <appname>
$ manage.py migrate --fake
$ python manage.py makemigrations
$ python manage.py migrate
$ python manage.py makemigrations <application name>
Migrations for 'books':
books/migrations/0003_auto.py:
- Alter field author on book
$ python manage.py migrate
Operations to perform:
Apply all migrations: books
Running migrations:
Rendering model states... DONE
Applying books.0003_auto... OK
# Generated by Django 2.2.5 on 2019-09-25 06:00
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name ='GeeksModel',
fields =[
('id', models.AutoField(auto_created = True,
primary_key = True, serialize = False,
verbose_name ='ID')),], ),
]
$ python manage.py migrate
Operations to perform:
Apply all migrations: books
Running migrations:
Rendering model states... DONE
Applying books.0003_auto... OK