Flake8 plugin to lint for backwards incompatible database migrations
Project description
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
Built Distribution
File details
Details for the file flake8-django-migrations-0.2.0.tar.gz
.
File metadata
- Download URL: flake8-django-migrations-0.2.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b959c2becaaf2c77673bf99227c388653ee81e72392d6bce7c709a1220c3270 |
|
MD5 | 76a74b3a1da01d8d28b054c060c91740 |
|
BLAKE2b-256 | 82c611bf2bee5f7a1a6fd29c37b4cea25bf545f3dfb5af0e3ce751186437d5fa |
File details
Details for the file flake8_django_migrations-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: flake8_django_migrations-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a0425caa97ee00fe15f97db82897b5cd14fc786aa7673db14f5a8aedba8c12f |
|
MD5 | 25ca637bf8493a5b1f0a545a988dd670 |
|
BLAKE2b-256 | 42c1dfdcc725cd1c27e49a892b774e99cfd3493555806fdc76019adc0dee57ec |