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.1.1.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.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for flake8_django_migrations-1.1.1.tar.gz
Algorithm Hash digest
SHA256 e2466a90d3092044002562b3c032159ee074510dbfe22672767ecda3f90430b6
MD5 71519c48f7ad402c7b3b7a2ef7ad692c
BLAKE2b-256 d1bfa0788c5556ebc81903a01c1a5eb903bc5a3335c84cff5c3d9bee7119b056

See more details on using hashes here.

Provenance

The following attestation bundles were made for flake8_django_migrations-1.1.1.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.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_django_migrations-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae79120ebf728ee97a8be4f6b2ee2debec04687344e59041a226e26c621f6b02
MD5 b57d79194e870932e94faa2d2e6709a2
BLAKE2b-256 9fc6f0a0106acede2cf3e0ccb3b15a03e2ea318cc0c7731465b9225a7d46e192

See more details on using hashes here.

Provenance

The following attestation bundles were made for flake8_django_migrations-1.1.1-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