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

Uploaded Source

Built Distribution

File details

Details for the file flake8-django-migrations-0.1.1.tar.gz.

File metadata

  • Download URL: flake8-django-migrations-0.1.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for flake8-django-migrations-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a38f163b20741a741b90a225bd764c6b785043df07e992feed38b3c79232b916
MD5 f3610ec247f831fbe9e5f42dd522bf35
BLAKE2b-256 e1b3fbef14f3dbe6fdef71a12b31c703ef3a412050c12c71d21a9761788d9499

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flake8_django_migrations-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for flake8_django_migrations-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9e66831533ce9f5470ba671d8b7c93ac659c2fad35d3fbcb0a8ec44c22c084b4
MD5 18c305351c9d7cde042414fd779ab8f1
BLAKE2b-256 501710b7c6885791d3abcf5f20c16065cc1cf64062efe5b86eece0280de2fc19

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