Skip to main content

Flake8 plugin to lint for backwards incompatible database migrations

Project description

flake8-django-migrations

CI Status Test coverage percentage

uv Ruff pre-commit

PyPi Status pyversions license


Source Code: https://github.com/browniebroke/flake8-django-migrations


Flake8 plugin to lint for backwards incompatible database migrations.

Installation

Install using pip (or your favourite package manager):

pip install flake8-django-migrations

Usage

This plugin should be used automatically when running flake8:

flake8

Checks

This is the list of checks currently implemented by this plugin.

DM001

RemoveField operation should be wrapped in SeparateDatabaseAndState.

Such an operation should be run in two separate steps, using SeparateDatabaseAndState, otherwise it is not backwards compatible.

  • Step 1: remove the field from the model and code. For foreign key fields, the foreign key constraint should also be dropped.
  • Step 2: remove the column from the database.

Bad

class Migration(migrations.Migration):
    operations = [
        migrations.RemoveField(
            model_name="order",
            name="total",
        ),
    ]

Good

class Migration(migrations.Migration):
    operations = [
        migrations.SeparateDatabaseAndState(
            state_operations=[
                migrations.RemoveField(
                    model_name="order",
                    name="total",
                ),
            ],
        ),
    ]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_django_migrations-1.2.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flake8_django_migrations-1.2.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file flake8_django_migrations-1.2.0.tar.gz.

File metadata

  • Download URL: flake8_django_migrations-1.2.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flake8_django_migrations-1.2.0.tar.gz
Algorithm Hash digest
SHA256 2212a3cd96e9be0b20564e55e038043a4b5758bec8983e2d9db70f5d17eced7a
MD5 52efa087cb056c1bb6ae5ddaa1d7a036
BLAKE2b-256 02dbc9b707987e975b2bbb3eed14fe5e7efedbcb095cbe3dd4759aee8beb6999

See more details on using hashes here.

Provenance

The following attestation bundles were made for flake8_django_migrations-1.2.0.tar.gz:

Publisher: ci.yml on browniebroke/flake8-django-migrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flake8_django_migrations-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_django_migrations-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae60f5074cc69686ff3b43cd15acb0cfae763cb3cc4988c0cbc2e862350a7049
MD5 1d855cacfe67232cf005a7195c381873
BLAKE2b-256 0f173bac46d669a7b2dc3837cff26139f98351795ca9a22cae4a3716f6a9c300

See more details on using hashes here.

Provenance

The following attestation bundles were made for flake8_django_migrations-1.2.0-py3-none-any.whl:

Publisher: ci.yml on browniebroke/flake8-django-migrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page