# 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
Creating the database tables to store your Django models is the job of a
database migration.
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.
In your activated python environment, run
$ 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
$ python manage.py migrate
Operations to perform:
Apply all migrations: books
Running migrations:
Rendering model states... DONE
Applying books.0003_auto... OK