Django Database Introspection

Check the differences between the Django Models and Database

Install django-extensions

pip install django-extensions==3.1.5

Add django-extensions to INSTALLED_APPS

In your django project add `django_extensions` in to the INSTALLED_APPS

INSTALLED_APPS = [
    "django.contrib.admin",  # admin interface
    "django.contrib.auth",  # django authentication
    "django.contrib.contenttypes", 
    ...
    ...
    ...
    "django_extensions",  # django extensions
]

Introspection

To get the differences between the Models and the Database, run the below commands

export DJANGO_SETTINGS_MODULE=sales_crm_backend.settings.<stage>

and set all the environment variables (set all variables which have been set in the Lambda function)

Then run the below command:

python manage.py sqldiff -a >> /tmp/sql_db_sales_crm_diff.txt

Check the file `/tmp/sql_db_sales_crm_diff.txt` and update accordingly

Last updated