Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max migration file computes incorrect max-migration, in case earlier migrations before installing the library have custom names, not starting with numbers. #161

Closed
shikhart98 opened this issue Mar 3, 2022 · 6 comments · Fixed by #208

Comments

@shikhart98
Copy link

shikhart98 commented Mar 3, 2022

Python Version

3.8

Django Version

2.2.5

Package Version

2.3.0

Description

Max migration file computes incorrect max-migration, in case earlier migrations before installing the library have custom names, not starting with numbers.

Example:

  • app
    • migrations
      | - 001.py
      | - 002.py
      | - custom_migration_name.py
      | - 003.py

in above migration folder actual dependency chain is: 001 -> 002 -> custom_migration_name -> 003

But when I am generating max migration file here I am getting custom_migration_name value over there, when my actual latest migration is 003.

@adamchainz
Copy link
Owner

Please provide an example rather than a one line description.

@shikhart98
Copy link
Author

@adamchainz Updated the description.

@adamchainz
Copy link
Owner

Is this when you use create_max_migration_files, or later when you use makemigrations?

@shikhart98
Copy link
Author

When I use create_max_migration_files.

@shikhart98
Copy link
Author

@adamchainz any update on this?

@adamchainz
Copy link
Owner

Currently we use max(migration_details.names) in a couple places to find the latest migration. I guess to be strictly correct, we need to change to using Django's MigrationLoader class to build the migration graph, when we can detect the final migration. This would also let us detect conflicts where there are multiple leaf migrations, like migrate does, by calling the loader's detect_conflicts() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants