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

Compare versions of migrations without namespace #1421

Open
wants to merge 1 commit into
base: 3.7.x
Choose a base branch
from

Conversation

beregovoy
Copy link

@beregovoy beregovoy commented Apr 4, 2024

Strip namespace, so namespace do not affect version comparsion.

Q A
Type bug/feature/improvement
BC Break no
Fixed issues

Summary

Previous behaviour
Migrations\Version2022 will always migrate AFTER Brand\Migrations\Version2024, but based on pure versions - Version2022 SHOULD be migrated BEFORE Version2024.

ZBrand\Migrations\Version2024 - will migrate AFTER Migrations\Version2022. So comparsion was not actually performed on version, but on namespace first. Which is kind of wrong, non intuitive, and break namespace functional.

New behaviour ignore namespace, and compare versions only by version. Default behaviour should not depend on namespace. If someone need to override it - he should did it explicitly for project.

Strip namespace, so namespace do not affect version comparsion.
@beregovoy
Copy link
Author

I may add tests, if concept will be accepted

@beregovoy beregovoy changed the title Update AlphabeticalComparator.php Compare versions of migrations without namespace Apr 4, 2024
@SenseException
Copy link
Member

Hi @beregovoy

it does make sense to have some expectations about the order of executed, but changing this in version 3.7 would be a bc break. I'd expect that this could be the default comparator in 4.0. A new comparator instance could still be injected manually in older versions though.

@HenryVolkmer
Copy link

Hi folks,
Hi @Ocramius,

Regarding the BCs, I propose to implement the fix as outlined here rather than modifying the Comparator.

This approach only changes the string representation of Version-Class, which ensures that already migrated data remains unaffected. Additionally, the alpha-comparator now sorts versions correctly.

As a result, the version string will look like this: Version20250114110700 (Foo\Bar\Migrations)
(Note: This change applies only to V3 versions, legacy versions remain untouched.)

.. and 5 tests will need to be adjusted accordingly

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 this pull request may close these issues.

3 participants