--- id: django-pg-migration-tools version: "0.1.26" 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) license_treatment: permissive maintenance: active --- # django-pg-migration-tools — Tools for making Django migrations safer and more scalable. License: permissive · Maintenance: active · Downloads: 76.2K/mo ## 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 above — 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 pip install django-pg-migration-tools uv add django-pg-migration-tools 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_current - Install friction: low - Maintenance: active - Downloads: 76.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django postgres migration safety, concurrent index operations django, postgres constraint migrations, django migration timeouts, safer database schema changes, postgres lock timeout management, django migration best practices, django-orm, postgres-specific, schema-migration [View on SkillFed](https://skillfed.io/packages/django-pg-migration-tools) · [View on PyPI](https://pypi.org/project/django-pg-migration-tools/)