{"id":19057184,"url":"https://github.com/3yourmind/django-migration-linter","last_synced_at":"2025-05-14T01:05:53.238Z","repository":{"id":19565433,"uuid":"87307127","full_name":"3YOURMIND/django-migration-linter","owner":"3YOURMIND","description":":rocket: Detect backward incompatible migrations for your django project","archived":false,"fork":false,"pushed_at":"2025-03-30T17:46:03.000Z","size":623,"stargazers_count":549,"open_issues_count":21,"forks_count":63,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-06T16:01:08.813Z","etag":null,"topics":["database","django","linter","migrations","mysql","postgresql","python"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/django-migration-linter/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/3YOURMIND.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-05T12:33:19.000Z","updated_at":"2025-04-01T11:53:40.000Z","dependencies_parsed_at":"2023-02-18T08:01:31.309Z","dependency_job_id":"de477c88-68f4-40e7-936b-2a0f7f826b67","html_url":"https://github.com/3YOURMIND/django-migration-linter","commit_stats":{"total_commits":432,"total_committers":31,"mean_commits":"13.935483870967742","dds":"0.32638888888888884","last_synced_commit":"202a6d9d5dea83528cb52fd7481a5a0565cc6f83"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3YOURMIND%2Fdjango-migration-linter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3YOURMIND%2Fdjango-migration-linter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3YOURMIND%2Fdjango-migration-linter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3YOURMIND%2Fdjango-migration-linter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/3YOURMIND","download_url":"https://codeload.github.com/3YOURMIND/django-migration-linter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248759390,"owners_count":21157150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","django","linter","migrations","mysql","postgresql","python"],"created_at":"2024-11-08T23:53:43.720Z","updated_at":"2025-04-13T18:25:22.479Z","avatar_url":"https://github.com/3YOURMIND.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django migration linter\r\n\r\nDetect backward incompatible migrations for your Django project.\r\nIt will save you time by making sure migrations will not break with a older codebase.\r\n\r\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2F3YOURMIND%2Fdjango-migration-linter%2Fbadge%3Fref%3Dmain\u0026style=flat)](https://actions-badge.atrox.dev/3YOURMIND/django-migration-linter/goto?ref=main)\r\n[![PyPI](https://img.shields.io/pypi/v/django-migration-linter.svg)](https://pypi.python.org/pypi/django-migration-linter/)\r\n[![PR_Welcome](https://img.shields.io/badge/PR-welcome-green.svg)](https://github.com/3YOURMIND/django-migration-linter/pulls)\r\n[![3YD_Hiring](https://img.shields.io/badge/3YOURMIND-Hiring-brightgreen.svg)](https://www.3yourmind.com/career)\r\n[![GitHub_Stars](https://img.shields.io/github/stars/3YOURMIND/django-migration-linter.svg?style=social\u0026label=Stars)](https://github.com/3YOURMIND/django-migration-linter/stargazers)\r\n\r\n## Quick installation\r\n\r\n```\r\npip install django-migration-linter\r\n```\r\n\r\nAnd add the migration linter to your ``INSTALLED_APPS``:\r\n```\r\nINSTALLED_APPS = [\r\n    ...,\r\n    \"django_migration_linter\",\r\n    ...,\r\n]\r\n```\r\n\r\nOptionally, add a configuration:\r\n```\r\nMIGRATION_LINTER_OPTIONS = {\r\n    ...\r\n}\r\n```\r\n\r\nFor details about configuration options, checkout [Usage](docs/usage.md).\r\n\r\n## Usage example\r\n\r\n```\r\n$ python manage.py lintmigrations\r\n\r\n(app_add_not_null_column, 0001_create_table)... OK\r\n(app_add_not_null_column, 0002_add_new_not_null_field)... ERR\r\n        NOT NULL constraint on columns\r\n(app_drop_table, 0001_initial)... OK\r\n(app_drop_table, 0002_delete_a)... ERR\r\n        DROPPING table\r\n(app_ignore_migration, 0001_initial)... OK\r\n(app_ignore_migration, 0002_ignore_migration)... IGNORE\r\n(app_rename_table, 0001_initial)... OK\r\n(app_rename_table, 0002_auto_20190414_1500)... ERR\r\n        RENAMING tables\r\n\r\n*** Summary ***\r\nValid migrations: 4/8\r\nErroneous migrations: 3/8\r\nMigrations with warnings: 0/8\r\nIgnored migrations: 1/8\r\n```\r\n\r\nThe linter analysed all migrations from the Django project.\r\nIt found 3 migrations that are doing backward incompatible operations and 1 that is explicitly ignored.\r\nThe list of incompatibilities that the linter analyses [can be found at docs/incompatibilities.md](./docs/incompatibilities.md).\r\n\r\nMore advanced usages of the linter and options [can be found at docs/usage.md](./docs/usage.md).\r\n\r\n## Integration\r\n\r\nOne can either integrate the linter in the CI using its `lintmigrations` command, or detect incompatibilities during generation of migrations with\r\n```\r\n$ python manage.py makemigrations --lint\r\n\r\nMigrations for 'app_correct':\r\n  tests/test_project/app_correct/migrations/0003_a_column.py\r\n    - Add field column to a\r\nLinting for 'app_correct':\r\n(app_correct, 0003_a_column)... ERR\r\n        NOT NULL constraint on columns\r\n\r\nThe migration linter detected that this migration is not backward compatible.\r\n- If you keep the migration, you will want to fix the issue or ignore the migration.\r\n- By default, the newly created migration file will be deleted.\r\nDo you want to keep the migration? [y/N] n\r\nDeleted tests/test_project/app_correct/migrations/0003_a_column.py\r\n```\r\n\r\nThe linter found that the newly created migration is not backward compatible and deleted the file after confirmation.\r\nThis behaviour can be the default of the `makemigrations` command through the `MIGRATION_LINTER_OVERRIDE_MAKEMIGRATIONS` Django setting.\r\nFind out more about the [makemigrations command at docs/makemigrations.md](./docs/makemigrations.md).\r\n\r\n### More information\r\n\r\nPlease find more documentation [in the docs/ folder](./docs/).\r\n\r\nSome implementation details [can be found in the ./docs/internals/ folder](./docs/internals/).\r\n\r\n### Blog post\r\n\r\n* [Keeping Django database migrations backward compatible](https://medium.com/3yourmind/keeping-django-database-migrations-backward-compatible-727820260dbb)\r\n* [Django and its default values](https://medium.com/botify-labs/django-and-its-default-values-c21a13cff9f)\r\n\r\n### They talk about the linter\r\n\r\n* [Django News](https://django-news.com/issues/6?m=web#uMmosw7)\r\n* [wemake-django-template](https://wemake-django-template.readthedocs.io/en/latest/pages/template/linters.html#django-migration-linter)\r\n* [Testing Django migrations on sobolevn's blog](https://sobolevn.me/2019/10/testing-django-migrations#existing-setup)\r\n\r\n### Related\r\n\r\n* [django-test-migrations](https://github.com/wemake-services/django-test-migrations) - Test django schema and data migrations, including migrations' order and best practices.\r\n\r\n### License\r\n\r\n*django-migration-linter* is released under the [Apache 2.0 License](./LICENSE).\r\n\r\n##### Maintained by [David Wobrock](https://github.com/David-Wobrock)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3yourmind%2Fdjango-migration-linter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F3yourmind%2Fdjango-migration-linter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3yourmind%2Fdjango-migration-linter/lists"}