Skip to main content

Flake8 plugin to lint for backwards incompatible database migrations

Project description

flake8-django-migrations

CI Status Test coverage percentage

Poetry 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.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

flake8_django_migrations-1.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for flake8_django_migrations-1.1.0.tar.gz
Algorithm Hash digest
SHA256 0c158f4b5cbb3910488746e1cc3d70b3d49b025ad133440ff4e87af30ea9cc51
MD5 5d12194ba45c7388c70a87ffe716a5d8
BLAKE2b-256 ce0e38fd925b050e006c15644ccdad28f3c3dff1f12b283daeaef02dbfb44f1d

See more details on using hashes here.

Provenance

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

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

Attestations:

File details

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

File metadata

File hashes

Hashes for flake8_django_migrations-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1dc8d35648ed4d006f3bb7c757fe3afbf243a665baf9b871baec52a4d0389e83
MD5 f904f13ddf6ea50d39553bbca7c29f20
BLAKE2b-256 5fec56fc9f4f41f883e14b96a1a41cc40b8d34d740f167c8fd9b07331638a316

See more details on using hashes here.

Provenance

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

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

Attestations:

Supported by

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