Skip to main content

Flake8 plugin to lint for backwards incompatible database migrations

Project description

flake8-django-migrations

CI Status Test coverage percentage

Poetry black pre-commit

PyPi Status pyversions license

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-0.3.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

flake8_django_migrations-0.3.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flake8_django_migrations-0.3.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.15

File hashes

Hashes for flake8_django_migrations-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1ffc96ff1b933024e47c39f9c70dfb8799f832db164f8df6acdafcf9de703474
MD5 a27640169cdafb1505a4503ac103c543
BLAKE2b-256 302accecfa8aab29e28c1efc6acfa2eefd661eae9d37b4ed14c9121cd388ca94

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flake8_django_migrations-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.15

File hashes

Hashes for flake8_django_migrations-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 49988dcc65e7f6fb811d6069adc49218bac736b3c35b8dddaf1455b9b2987091
MD5 2e19d911698cb2fa56163187c3c856db
BLAKE2b-256 76c8fd9148a138b422207a9cd5626c127b87e89dcb824a267953ea89a9a698d9

See more details on using hashes here.

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