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

Moved migration sorting from MigrationRepository to MigrationPlanCalculator #969

Merged
merged 2 commits into from
May 8, 2020
Merged

Moved migration sorting from MigrationRepository to MigrationPlanCalculator #969

merged 2 commits into from
May 8, 2020

Conversation

goetas
Copy link
Member

@goetas goetas commented Apr 23, 2020

Q A
Type improvement
BC Break -
Fixed issues -

This change will allow to define sorting by looking into the available migrations array. Before this change was not possible as the same object responsible for sorting migrations, was responsible also for locating migrations (this the circular dependency..).

@goetas goetas added this to the 3.0.0 milestone Apr 23, 2020
Copy link
Member Author

@goetas goetas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

@riccardonar You can fix CS failures running vendor/bin/phpcs.

@goetas goetas marked this pull request as ready for review April 29, 2020 04:57
@goetas goetas requested a review from greg0ire April 29, 2020 07:59
@goetas goetas marked this pull request as draft May 1, 2020 19:14
@goetas
Copy link
Member Author

goetas commented May 2, 2020

This pull request brings an interesting point. Are executed migrations sorted? if yes, how? using the same sorting for available migrations?

if they are not sorted, ExecutedMigrationsSet should not have the getLast and getFirst methods, but then it becomes hard to to find the current migration status

@riccardonar
Copy link
Contributor

This pull request brings an interesting point. Are executed migrations sorted? if yes, how? using the same sorting for available migrations?

if they are not sorted, ExecutedMigrationsSet should not have the getLast and getFirst methods, but then it becomes hard to to find the current migration status

Couldn't ExecutedMigrationsSet be sorted by the time it was recorded as executed on db?
Certainly the ordering between executed and available could change

@goetas
Copy link
Member Author

goetas commented May 3, 2020

This pull request brings an interesting point. Are executed migrations sorted? if yes, how? using the same sorting for available migrations?

if they are not sorted, ExecutedMigrationsSet should not have the getLast and getFirst methods, but then it becomes hard to to find the current migration status

Couldn't ExecutedMigrationsSet be sorted by the time it was recorded as executed on db?
Certainly the ordering between executed and available could change

#974 will solve that

…ulator

This change will allow to define sorting by looking into the available migrations array. Before this change was not possible as the same object responsible for sorting migrations, was responsible also for locating migrations.
@goetas goetas marked this pull request as ready for review May 6, 2020 05:50
@goetas
Copy link
Member Author

goetas commented May 6, 2020

This is ready for review!

lib/Doctrine/Migrations/Metadata/AvailableMigration.php Outdated Show resolved Hide resolved
lib/Doctrine/Migrations/Metadata/ExecutedMigration.php Outdated Show resolved Hide resolved
lib/Doctrine/Migrations/Metadata/MigrationPlan.php Outdated Show resolved Hide resolved
lib/Doctrine/Migrations/Metadata/MigrationPlanList.php Outdated Show resolved Hide resolved
*/
final class AvailableMigrationsSet implements Countable
{
/** @var AvailableMigration[] */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have array_values

Suggested change
/** @var AvailableMigration[] */
/** @var list<AvailableMigration> */

Copy link
Member Author

@goetas goetas May 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this compatible with common IDEs ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's compatible with vim :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative suggested here:

Suggested change
/** @var AvailableMigration[] */
/**
* @var AvailableMigration[]
* @phpstan-var AvailableMigration[]
* @psalm-var AvailableMigration[]
*/

Not that the second one is superflous: both tools read each other's annotations

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally do not like this "tool" specific annotations... if a third tool will emerge will need to add them too... i suggest to leave AvailableMigration[] as it is

}

/**
* @return AvailableMigration[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return AvailableMigration[]
* @return list<AvailableMigration>

Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should discuss as a team what we want regarding annotations, anyway it's not a good reason to block this PR.

@goetas
Copy link
Member Author

goetas commented May 8, 2020

I'm merging this. The conversation about list or [] can be discussed again in the future at it will impact the whole codebase, not only the changes in this PR.

@goetas goetas merged commit ebd2551 into doctrine:master May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants