django-migration-linter


Namedjango-migration-linter JSON
Version 5.1.0 PyPI version JSON
download
home_pageNone
SummaryDetect backward incompatible migrations for your django project
upload_time2024-03-30 11:00:08
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords django migration lint linter database backward compatibility
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django migration linter

Detect backward incompatible migrations for your Django project.
It will save you time by making sure migrations will not break with a older codebase.

[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2F3YOURMIND%2Fdjango-migration-linter%2Fbadge%3Fref%3Dmain&style=flat)](https://actions-badge.atrox.dev/3YOURMIND/django-migration-linter/goto?ref=main)
[![PyPI](https://img.shields.io/pypi/v/django-migration-linter.svg)](https://pypi.python.org/pypi/django-migration-linter/)
[![PR_Welcome](https://img.shields.io/badge/PR-welcome-green.svg)](https://github.com/3YOURMIND/django-migration-linter/pulls)
[![3YD_Hiring](https://img.shields.io/badge/3YOURMIND-Hiring-brightgreen.svg)](https://www.3yourmind.com/career)
[![GitHub_Stars](https://img.shields.io/github/stars/3YOURMIND/django-migration-linter.svg?style=social&label=Stars)](https://github.com/3YOURMIND/django-migration-linter/stargazers)

## Quick installation

```
pip install django-migration-linter
```

And add the migration linter to your ``INSTALLED_APPS``:
```
INSTALLED_APPS = [
    ...,
    "django_migration_linter",
    ...,
]
```

Optionally, add a configuration:
```
MIGRATION_LINTER_OPTIONS = {
    ...
}
```

For details about configuration options, checkout [Usage](docs/usage.md).

## Usage example

```
$ python manage.py lintmigrations

(app_add_not_null_column, 0001_create_table)... OK
(app_add_not_null_column, 0002_add_new_not_null_field)... ERR
        NOT NULL constraint on columns
(app_drop_table, 0001_initial)... OK
(app_drop_table, 0002_delete_a)... ERR
        DROPPING table
(app_ignore_migration, 0001_initial)... OK
(app_ignore_migration, 0002_ignore_migration)... IGNORE
(app_rename_table, 0001_initial)... OK
(app_rename_table, 0002_auto_20190414_1500)... ERR
        RENAMING tables

*** Summary ***
Valid migrations: 4/8
Erroneous migrations: 3/8
Migrations with warnings: 0/8
Ignored migrations: 1/8
```

The linter analysed all migrations from the Django project.
It found 3 migrations that are doing backward incompatible operations and 1 that is explicitly ignored.
The list of incompatibilities that the linter analyses [can be found at docs/incompatibilities.md](./docs/incompatibilities.md).

More advanced usages of the linter and options [can be found at docs/usage.md](./docs/usage.md).

## Integration

One can either integrate the linter in the CI using its `lintmigrations` command, or detect incompatibilities during generation of migrations with
```
$ python manage.py makemigrations --lint

Migrations for 'app_correct':
  tests/test_project/app_correct/migrations/0003_a_column.py
    - Add field column to a
Linting for 'app_correct':
(app_correct, 0003_a_column)... ERR
        NOT NULL constraint on columns

The migration linter detected that this migration is not backward compatible.
- If you keep the migration, you will want to fix the issue or ignore the migration.
- By default, the newly created migration file will be deleted.
Do you want to keep the migration? [y/N] n
Deleted tests/test_project/app_correct/migrations/0003_a_column.py
```

The linter found that the newly created migration is not backward compatible and deleted the file after confirmation.
This behaviour can be the default of the `makemigrations` command through the `MIGRATION_LINTER_OVERRIDE_MAKEMIGRATIONS` Django setting.
Find out more about the [makemigrations command at docs/makemigrations.md](./docs/makemigrations.md).

### More information

Please find more documentation [in the docs/ folder](./docs/).

Some implementation details [can be found in the ./docs/internals/ folder](./docs/internals/).

### Blog post

* [Keeping Django database migrations backward compatible](https://medium.com/3yourmind/keeping-django-database-migrations-backward-compatible-727820260dbb)
* [Django and its default values](https://medium.com/botify-labs/django-and-its-default-values-c21a13cff9f)

### They talk about the linter

* [Django News](https://django-news.com/issues/6?m=web#uMmosw7)
* [wemake-django-template](https://wemake-django-template.readthedocs.io/en/latest/pages/template/linters.html#django-migration-linter)
* [Testing Django migrations on sobolevn's blog](https://sobolevn.me/2019/10/testing-django-migrations#existing-setup)

### Related

* [django-test-migrations](https://github.com/wemake-services/django-test-migrations) - Test django schema and data migrations, including migrations' order and best practices.

### License

*django-migration-linter* is released under the [Apache 2.0 License](./LICENSE).

##### Maintained by [David Wobrock](https://github.com/David-Wobrock)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-migration-linter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "David Wobrock <david.wobrock@gmail.com>",
    "keywords": "django, migration, lint, linter, database, backward, compatibility",
    "author": null,
    "author_email": "3YOURMIND GmbH <fb@3yourmind.com>",
    "download_url": "https://files.pythonhosted.org/packages/f3/2d/89b5a1d0f0bffd6950a61c4826f8d34294ed6900e0947db953f7c23f9e07/django-migration-linter-5.1.0.tar.gz",
    "platform": null,
    "description": "# Django migration linter\n\nDetect backward incompatible migrations for your Django project.\nIt will save you time by making sure migrations will not break with a older codebase.\n\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2F3YOURMIND%2Fdjango-migration-linter%2Fbadge%3Fref%3Dmain&style=flat)](https://actions-badge.atrox.dev/3YOURMIND/django-migration-linter/goto?ref=main)\n[![PyPI](https://img.shields.io/pypi/v/django-migration-linter.svg)](https://pypi.python.org/pypi/django-migration-linter/)\n[![PR_Welcome](https://img.shields.io/badge/PR-welcome-green.svg)](https://github.com/3YOURMIND/django-migration-linter/pulls)\n[![3YD_Hiring](https://img.shields.io/badge/3YOURMIND-Hiring-brightgreen.svg)](https://www.3yourmind.com/career)\n[![GitHub_Stars](https://img.shields.io/github/stars/3YOURMIND/django-migration-linter.svg?style=social&label=Stars)](https://github.com/3YOURMIND/django-migration-linter/stargazers)\n\n## Quick installation\n\n```\npip install django-migration-linter\n```\n\nAnd add the migration linter to your ``INSTALLED_APPS``:\n```\nINSTALLED_APPS = [\n    ...,\n    \"django_migration_linter\",\n    ...,\n]\n```\n\nOptionally, add a configuration:\n```\nMIGRATION_LINTER_OPTIONS = {\n    ...\n}\n```\n\nFor details about configuration options, checkout [Usage](docs/usage.md).\n\n## Usage example\n\n```\n$ python manage.py lintmigrations\n\n(app_add_not_null_column, 0001_create_table)... OK\n(app_add_not_null_column, 0002_add_new_not_null_field)... ERR\n        NOT NULL constraint on columns\n(app_drop_table, 0001_initial)... OK\n(app_drop_table, 0002_delete_a)... ERR\n        DROPPING table\n(app_ignore_migration, 0001_initial)... OK\n(app_ignore_migration, 0002_ignore_migration)... IGNORE\n(app_rename_table, 0001_initial)... OK\n(app_rename_table, 0002_auto_20190414_1500)... ERR\n        RENAMING tables\n\n*** Summary ***\nValid migrations: 4/8\nErroneous migrations: 3/8\nMigrations with warnings: 0/8\nIgnored migrations: 1/8\n```\n\nThe linter analysed all migrations from the Django project.\nIt found 3 migrations that are doing backward incompatible operations and 1 that is explicitly ignored.\nThe list of incompatibilities that the linter analyses [can be found at docs/incompatibilities.md](./docs/incompatibilities.md).\n\nMore advanced usages of the linter and options [can be found at docs/usage.md](./docs/usage.md).\n\n## Integration\n\nOne can either integrate the linter in the CI using its `lintmigrations` command, or detect incompatibilities during generation of migrations with\n```\n$ python manage.py makemigrations --lint\n\nMigrations for 'app_correct':\n  tests/test_project/app_correct/migrations/0003_a_column.py\n    - Add field column to a\nLinting for 'app_correct':\n(app_correct, 0003_a_column)... ERR\n        NOT NULL constraint on columns\n\nThe migration linter detected that this migration is not backward compatible.\n- If you keep the migration, you will want to fix the issue or ignore the migration.\n- By default, the newly created migration file will be deleted.\nDo you want to keep the migration? [y/N] n\nDeleted tests/test_project/app_correct/migrations/0003_a_column.py\n```\n\nThe linter found that the newly created migration is not backward compatible and deleted the file after confirmation.\nThis behaviour can be the default of the `makemigrations` command through the `MIGRATION_LINTER_OVERRIDE_MAKEMIGRATIONS` Django setting.\nFind out more about the [makemigrations command at docs/makemigrations.md](./docs/makemigrations.md).\n\n### More information\n\nPlease find more documentation [in the docs/ folder](./docs/).\n\nSome implementation details [can be found in the ./docs/internals/ folder](./docs/internals/).\n\n### Blog post\n\n* [Keeping Django database migrations backward compatible](https://medium.com/3yourmind/keeping-django-database-migrations-backward-compatible-727820260dbb)\n* [Django and its default values](https://medium.com/botify-labs/django-and-its-default-values-c21a13cff9f)\n\n### They talk about the linter\n\n* [Django News](https://django-news.com/issues/6?m=web#uMmosw7)\n* [wemake-django-template](https://wemake-django-template.readthedocs.io/en/latest/pages/template/linters.html#django-migration-linter)\n* [Testing Django migrations on sobolevn's blog](https://sobolevn.me/2019/10/testing-django-migrations#existing-setup)\n\n### Related\n\n* [django-test-migrations](https://github.com/wemake-services/django-test-migrations) - Test django schema and data migrations, including migrations' order and best practices.\n\n### License\n\n*django-migration-linter* is released under the [Apache 2.0 License](./LICENSE).\n\n##### Maintained by [David Wobrock](https://github.com/David-Wobrock)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Detect backward incompatible migrations for your django project",
    "version": "5.1.0",
    "project_urls": {
        "Changelog": "https://github.com/3YOURMIND/django-migration-linter/blob/main/CHANGELOG.md",
        "Repository": "https://github.com/3YOURMIND/django-migration-linter"
    },
    "split_keywords": [
        "django",
        " migration",
        " lint",
        " linter",
        " database",
        " backward",
        " compatibility"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8f427439077973d9fc2826004925a6a231cbbd6e08faaac5e682dcb7b09e40e7",
                "md5": "b1ca94e362f6281754c8016e019fa7e4",
                "sha256": "eefdca0cd60b0bacdf61420b0779b2c680dd29d3b43e9ccb0d8d2aa89f036474"
            },
            "downloads": -1,
            "filename": "django_migration_linter-5.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b1ca94e362f6281754c8016e019fa7e4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 27017,
            "upload_time": "2024-03-30T11:00:06",
            "upload_time_iso_8601": "2024-03-30T11:00:06.212823Z",
            "url": "https://files.pythonhosted.org/packages/8f/42/7439077973d9fc2826004925a6a231cbbd6e08faaac5e682dcb7b09e40e7/django_migration_linter-5.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f32d89b5a1d0f0bffd6950a61c4826f8d34294ed6900e0947db953f7c23f9e07",
                "md5": "1dfa353f34d482aae4bfe7901bfbda9b",
                "sha256": "638a6f39b0109fb95a747f10cb3ae4362b4ca46e7f45eee9546d3dd4c322b83a"
            },
            "downloads": -1,
            "filename": "django-migration-linter-5.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1dfa353f34d482aae4bfe7901bfbda9b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 34834,
            "upload_time": "2024-03-30T11:00:08",
            "upload_time_iso_8601": "2024-03-30T11:00:08.713229Z",
            "url": "https://files.pythonhosted.org/packages/f3/2d/89b5a1d0f0bffd6950a61c4826f8d34294ed6900e0947db953f7c23f9e07/django-migration-linter-5.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-30 11:00:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "3YOURMIND",
    "github_project": "django-migration-linter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "django-migration-linter"
}
        
Elapsed time: 0.22639s