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.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a38f163b20741a741b90a225bd764c6b785043df07e992feed38b3c79232b916 |
|
MD5 | f3610ec247f831fbe9e5f42dd522bf35 |
|
BLAKE2b-256 | e1b3fbef14f3dbe6fdef71a12b31c703ef3a412050c12c71d21a9761788d9499 |
Close
Hashes for flake8_django_migrations-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e66831533ce9f5470ba671d8b7c93ac659c2fad35d3fbcb0a8ec44c22c084b4 |
|
MD5 | 18c305351c9d7cde042414fd779ab8f1 |
|
BLAKE2b-256 | 501710b7c6885791d3abcf5f20c16065cc1cf64062efe5b86eece0280de2fc19 |