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
Close
Hashes for flake8_django_migrations-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ffc96ff1b933024e47c39f9c70dfb8799f832db164f8df6acdafcf9de703474 |
|
MD5 | a27640169cdafb1505a4503ac103c543 |
|
BLAKE2b-256 | 302accecfa8aab29e28c1efc6acfa2eefd661eae9d37b4ed14c9121cd388ca94 |
Close
Hashes for flake8_django_migrations-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49988dcc65e7f6fb811d6069adc49218bac736b3c35b8dddaf1455b9b2987091 |
|
MD5 | 2e19d911698cb2fa56163187c3c856db |
|
BLAKE2b-256 | 76c8fd9148a138b422207a9cd5626c127b87e89dcb824a267953ea89a9a698d9 |