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

Uploaded Source

Built Distribution

File details

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

File metadata

  • Download URL: flake8-django-migrations-0.2.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.4 keyring/23.5.1 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13

File hashes

Hashes for flake8-django-migrations-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ee65f2d5997394ccac2c5de43c006e9e74c5457a54194a38831f79e8101532ed
MD5 ba1c78ccbafae1f02d6e47bd4da2c7de
BLAKE2b-256 ad7de4a214201e9983b2107a11d4f42ea666f10e5590ea5b2bcb27611e94c3d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flake8_django_migrations-0.2.1-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.2 readme-renderer/35.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.4 keyring/23.5.1 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13

File hashes

Hashes for flake8_django_migrations-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b12270c71fdb5ab5e3eca9bd98f12f9139ac95e52fd5e2fdc54343afa50bec1d
MD5 9ca3652671405f27d28dfe95d2e492fa
BLAKE2b-256 1932c54eda47215a48a090f4de3d6bdf81e7f39b75cb8e3e48b78f29d44edc67

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