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.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee65f2d5997394ccac2c5de43c006e9e74c5457a54194a38831f79e8101532ed |
|
MD5 | ba1c78ccbafae1f02d6e47bd4da2c7de |
|
BLAKE2b-256 | ad7de4a214201e9983b2107a11d4f42ea666f10e5590ea5b2bcb27611e94c3d4 |
Close
Hashes for flake8_django_migrations-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b12270c71fdb5ab5e3eca9bd98f12f9139ac95e52fd5e2fdc54343afa50bec1d |
|
MD5 | 9ca3652671405f27d28dfe95d2e492fa |
|
BLAKE2b-256 | 1932c54eda47215a48a090f4de3d6bdf81e7f39b75cb8e3e48b78f29d44edc67 |