Run Django's makemigrations as a pre-commit hook.
pre-commit hook to generate django migrations
See pre-commit for installation instructions
Sample basic .pre-commit-config.yaml
- repo: https://github.com/tj-pre-commit/django-makemigrations
rev: v1.0.0
hooks:
- id: django-makemigrations
stages: [commit]
Sample complex .pre-commit-config.yaml
- repo: https://github.com/tj-pre-commit/django-makemigrations
rev: v1.0.0
hooks:
- id: django-makemigrations
stages: [commit]
args: [
'--settings',
'project.settings', # Defaults to: DJANGO_SETTINGS_MODULE
'--merge', # Enables fixing of migration conflicts.
'--empty', # Creates an empty migration.
'--no-input', # Do not prompt for user input.
'--verbosity', # OR '-v'
'2', # Set the verbosity level {0,1,2,3}
# See https://docs.djangoproject.com/en/3.1/ref/django-admin/#makemigrations for more information
]