3YOURMIND / django-migration-linter

:rocket: Detect backward incompatible migrations for your django project
https://pypi.python.org/pypi/django-migration-linter/
Apache License 2.0
514 stars 56 forks source link

Migrations ignored from git_commit_id when the app label does not exactly match the folder name #249

Open phillipuniverse opened 1 year ago

phillipuniverse commented 1 year ago

Here's a screenshot from the Pycharm debugger that shows the issue

image

The migration linter is checking for a migration with a tuple ("netsuite", "0012_added_netsuite_suiteapp_config") against the Django disk_migrations (self.migration_loader is the Django MigrationLoader).

This migration linter assumes that "netsuite" is a valid app name for Django. But it's not - Django doesn't know about an app called netsuite, it knows about one called integrations_netsuite. This is because we renamed it in a custom AppConfig in apps.py:

 class NetsuiteConfig(AppConfig): 
     name = "integrations.netsuite" 
     label = name.replace(".", "_") 

So the root issue is that the linter doesn't look truly at app labels, it only looks at folder structures.

This appears to only be an issue when used in concert with the git commit id.

Fix for this issue is at #248 which takes the folder structure and converts it to the real Django app without assumptions about naming.

David-Wobrock commented 1 year ago

Hi @phillipuniverse

Thanks for the report! That's indeed something the linter should support. I'll try to look into it and review https://github.com/3YOURMIND/django-migration-linter/pull/248 soon :)

mjvankampen commented 4 months ago

Ran into this as well!