skillfed

django-pg-migration-tools

Tools for making Django migrations safer and more scalable.

django-pg-migration-tools v0.1.26 76.2K downloads/30d#14,650 on PyPI61
Permissive license BSD 3-Clause License Copyright (c) 2024, Kraken Technologies Limited Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following… (full text in the JSON record) Active released

What it is and what it does

django-pg-migration-tools is a Django package that wraps PostgreSQL-specific migration operations to make schema changes safer in production environments. It provides drop-in replacements for standard Django migration operations—adding/removing constraints, indexes, and foreign keys—that use PostgreSQL's non-blocking techniques (like concurrent index creation) and timeout controls to prevent migrations from locking tables and blocking application traffic.

The package includes management commands to run migrations with configurable statement and lock timeouts, and context managers to apply timeouts to arbitrary database operations. It's designed for teams running Django on PostgreSQL who need to perform schema changes on live databases without downtime or long-running locks. The codebase is actively maintained, supports modern Python versions, and carries no runtime dependencies beyond Django itself.

Use it for:

  • Add indexes to large production tables without blocking reads and writes during the migration window.
  • Add or remove unique and check constraints safely using PostgreSQL's non-blocking constraint creation.
  • Set columns to NOT NULL on populated tables by validating data before applying the constraint.
  • Run all migrations with automatic statement and lock timeouts to prevent runaway queries from blocking the application.
  • Add foreign keys to existing tables with validation and optional constraint deferral.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides safer, production-ready Django migration operations for PostgreSQL, including concurrent index management, constraint handling, and timeout controls to prevent long-running migrations from blocking production databases.

Yes, if you run Django on PostgreSQL and perform schema migrations on live databases. The package directly addresses a real production pain point—long-running migrations that lock tables—and is actively maintained with no external dependencies. The alpha status reflects early releases, but the core operations are straightforward and well-documented. Install if you need safer schema changes; skip if you use a different database backend or have no production migration concerns.

Install

django-pg-migration-tools on PyPI

pip

pip install django-pg-migration-tools

uv

uv add django-pg-migration-tools

poetry

poetry add django-pg-migration-tools

Installing django-pg-migration-tools

Before you install

Low friction installation with no runtime dependencies. Actively maintained as of 2026-02-27 with recent releases. Supports current Python versions (3.10 through 3.14).

License in practice

BSD 3-Clause License permits commercial and private use with minimal restrictions; you may modify and distribute freely provided you retain copyright notices and disclaimers.

Quickstart

pip install django-pg-migration-tools

from django_pg_migration_tools.operations import SaferAddIndexConcurrently

class Migration(migrations.Migration):
    operations = [
        SaferAddIndexConcurrently(
            model_name='mymodel',
            index=models.Index(fields=['field_name'])
        )
    ]

Requires Django and PostgreSQL; operations are PostgreSQL-specific and will not work with other database backends.

Verify before relying

  • Minimum Django version requirement not specified in fact sheet.
  • Whether all operations are backward-compatible with existing migration files.
  • Performance impact of safer operations compared to standard Django migrations.

Package facts

License BSD 3-Clause License Copyright (c) 2024, Kraken Technologies Limited Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 168 days since the last release
Last repo commit
First released
Downloads 76,180/month — #14,650 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_pg_migration_tools-0.1.26-py3-none-any.whl

Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Typing :: Typed

Tags

django postgres migration safetyconcurrent index operations djangopostgres constraint migrationsdjango migration timeoutssafer database schema changespostgres lock timeout managementdjango migration best practices
django-ormpostgres-specificschema-migration

More Database packages