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-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3f2a72d97159c3e86fba0581c85d9dd19b5a5872cff92f788ccbd8fdb435df7 |
|
MD5 | e03a95e9541a31d70a1ec0177bf249ad |
|
BLAKE2b-256 | 7cf1d74474aa62f389df6a6eed499ce7b7b71c3376f8b55d56bf46b2a86260cd |
Close
Hashes for flake8_django_migrations-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 838971daee6ab86e883a5bf9eab92a6f553a7eb2b60f2c43ee12975f2b192a06 |
|
MD5 | b0c88f05e70b8688bc38d975fce4bbb8 |
|
BLAKE2b-256 | 6e47efd88e37e5c59717c1d60f19e950d0bcbf0e944cd58d8c93db6bd25cddd6 |