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

Make column and index renaming configurable #6300

Open
wants to merge 9 commits into
base: 4.2.x
Choose a base branch
from

Conversation

ausi
Copy link
Contributor

@ausi ausi commented Feb 6, 2024

Q A
Type improvement
Fixed issues #6299

Summary

Makes column and index rename detection of the Comparator configurable, as suggested in #6299 (comment)

@ausi ausi force-pushed the feature/rename-columns-configurable branch from b663bfe to d0c8602 Compare March 11, 2024 13:12
Copy link

There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.
If you want to continue working on it, please leave a comment.

@github-actions github-actions bot added the Stale label Jun 10, 2024
@ausi
Copy link
Contributor Author

ausi commented Jun 10, 2024

I adressed all review comments.

Adressing this issue is quite important for us in order to get compatible with Doctrine 4.

@github-actions github-actions bot removed the Stale label Jun 11, 2024
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.

I think this lacks documentation, and I'm curious to see what a real-world usage would look like, since "The comparator can be only instantiated by a schema manager" (so, at runtime, rather than at DIC compilation time).

src/Schema/ComparatorConfig.php Outdated Show resolved Hide resolved
@ausi
Copy link
Contributor Author

ausi commented Jun 21, 2024

I think this lacks documentation,

Should I add a section for createComparator() to docs/en/reference/schema-manager.rst ?
Or should it be a new page about the Comparator itself?

and I'm curious to see what a real-world usage would look like, since "The comparator can be only instantiated by a schema manager" (so, at runtime, rather than at DIC compilation time).

We would use it here: https://github.com/contao/contao/blob/aa54c3df007e4b01b73e08036e35c054a7d1fd84/core-bundle/src/Migration/CommandCompiler.php#L61-L66 like this:

$comparator = $schemaManager->createComparator();
$config = new ComparatorConfig();
$config->setDetectRenamedColumns(false);
$config->setDetectRenamedIndexes(false);
$comparator->setConfig($config);
$diffCommands = $comparator
    ->compareSchemas($fromSchema, $toSchema)
    ->toSql($this->connection->getDatabasePlatform())
;

Are you happy with the setConfig() approach? I think I’d prefer a third parameter to the methods compareTables and compareSchemas instead, see #6300 (comment)

@greg0ire
Copy link
Member

I would drop setConfig, and add a new argument to createComparator, so that the config can be readonly. Having it mutable doesn't feel great.

@ausi
Copy link
Contributor Author

ausi commented Jun 21, 2024

Should I make the Config object itself also immutable?

@greg0ire
Copy link
Member

I think everything should be made immutable by default, yes. If people need to mutate anything, they will send a PR explaining their use case, making it mutable won't be a breaking change.

@greg0ire
Copy link
Member

Should I add a section for createComparator() to docs/en/reference/schema-manager.rst ?

A section feels enough

@ausi
Copy link
Contributor Author

ausi commented Jun 21, 2024

I think this lacks documentation

Done in e117bbb

@ausi ausi force-pushed the feature/rename-columns-configurable branch from dd9bc52 to b4195ae Compare June 24, 2024 18:34
@ausi
Copy link
Contributor Author

ausi commented Jun 24, 2024

Failing CI seems to be unrelated.

greg0ire
greg0ire previously approved these changes Jun 24, 2024
# Conflicts:
#	src/Schema/Comparator.php
@ausi
Copy link
Contributor Author

ausi commented Aug 15, 2024

As this didn’t make it into the 4.1.0 release, should I change the base branch to 4.2.x?

@derrabus derrabus changed the base branch from 4.1.x to 4.2.x August 15, 2024 08:34
@derrabus
Copy link
Member

Done. And please rebase your PR and fix the red CI checks.

@ausi
Copy link
Contributor Author

ausi commented Aug 15, 2024

Done.

@ausi
Copy link
Contributor Author

ausi commented Aug 15, 2024

…and fix the red CI checks.

Only the “Upload coverage to Codecov” job fails now. I’m not sure how to fix that.

@ausi ausi force-pushed the feature/rename-columns-configurable branch 3 times, most recently from 5b4f358 to c47b6ba Compare August 15, 2024 13:34
@derrabus
Copy link
Member

Only the “Upload coverage to Codecov” job fails now.

You can ignore that one.

@ausi ausi force-pushed the feature/rename-columns-configurable branch from c47b6ba to 05ad0d8 Compare August 15, 2024 15:21
@uncaught
Copy link

uncaught commented Sep 6, 2024

This looks quite similar to what I've just done in #6521 - I've injected the Configuration where you inject this new config class of yours.

However, I'm curious as to how I would configure this at the end-user-level? The doctrine-bundle configures the Configuration, so it would be easy enough to add new options there. But how will this work on your class?

In my symfony project I see several places outside the dbal that call createComparator(): doctrine/migrations, symfony/doctrine-messenger, doctrine/orm. Do we have to configure all those places individually, add PRs there? The config should surely be the same across all of them.

I'm fine with having a dedicated config sub-class for the comparator, but would it not make sense to have it also as property on the Configuration, and then inject it from there, rather via an argument of createComparator?

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.

6 participants