{"repo":"AmbitionEng/django-pgmigrate","free":true,"listed":false,"github":"https://github.com/AmbitionEng/django-pgmigrate","clone":"git clone https://github.com/AmbitionEng/django-pgmigrate.git","description":"Avoid costly downtime during Postgres migrations.","language":"Python","stars":28,"topics":["django","migrations","postgresql"],"license":"BSD-3-Clause","category":"databases-storage","readme_excerpt":"django-pgmigrate django-pgmigrate helps you avoid costly downtime with Postgres migrations. Imagine the following happens: 1. A long-running task queries a model in a transaction and keeps the transaction open. 2. python manage.py migrate tries to change a field on the model. Because of how Postgres queues locks, this common scenario causes every subsequent query on the model to block until the query from 1) has finished. django-pgmigrate provides the following features to alleviate problematic locking scenarios when running migrations: Detect blocking queries and terminate them automatically (the default behavior). Print blocking queries so that you can inspect and terminate them manually. Set the lock timeout so that migrations are terminated if they block too long. Installation Install django-pgmigrate with: pip3 install django-pgmigrate After this, add pgactivity , pglock , and pgmigrate to the INSTALLED APPS setting of your Django project. Quick Start After following the installation instructions, running python manage.py migrate will automatically terminate any blocking queries. Here's an example of what it looks like: There are two additional outputs in the migrate command versus the original: 1. The first output line shows the Postgres process ID. This is useful for querying activity that's blocking the process. 2. The yellow text shows when a blocking query was detected and terminated. In our case, it was blocking auth migration 12. You can configure django-pgmigrate","default_branch":null,"files":null,"tree":[],"storefront":"/r/AmbitionEng","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/AmbitionEng/django-pgmigrate/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}