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

Uploaded Source

Built Distribution

flake8_django_migrations-1.0.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flake8_django_migrations-1.0.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.3 tqdm/4.65.0 importlib-metadata/6.7.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.12

File hashes

Hashes for flake8_django_migrations-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f3f2a72d97159c3e86fba0581c85d9dd19b5a5872cff92f788ccbd8fdb435df7
MD5 e03a95e9541a31d70a1ec0177bf249ad
BLAKE2b-256 7cf1d74474aa62f389df6a6eed499ce7b7b71c3376f8b55d56bf46b2a86260cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flake8_django_migrations-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.3 tqdm/4.65.0 importlib-metadata/6.7.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.12

File hashes

Hashes for flake8_django_migrations-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 838971daee6ab86e883a5bf9eab92a6f553a7eb2b60f2c43ee12975f2b192a06
MD5 b0c88f05e70b8688bc38d975fce4bbb8
BLAKE2b-256 6e47efd88e37e5c59717c1d60f19e950d0bcbf0e944cd58d8c93db6bd25cddd6

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