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

Schema Diff API cleanup #5622

Merged
merged 2 commits into from
Aug 27, 2022
Merged

Schema Diff API cleanup #5622

merged 2 commits into from
Aug 27, 2022

Conversation

morozov
Copy link
Member

@morozov morozov commented Aug 27, 2022

  1. Mark schema diff constructors as internal. Schema diff objects are meant to be instantiated only by schema
    comparators. As a cleanup of the old property-based schema comparison logic, we will eventually remove the $changedProperties parameter of the ColumnDiff class.
  2. The $oldColumnName property and the corresponding constructor parameter were relevant until Added support for alter table, foreign keys and autoincrement detection to Sqlite platform and schema #220 (2.4.0) which introduced the $fromColumn property and the corresponding constructor parameter. Now they are redundant. The same applies to getOldColumnName(). The $fromColumn property contains all the properties of the old column including the name.

Schema diff objects are meant to be instantiated only by schema
comparators.

As a cleanup of the old property-based schema comparison logic, we will
eventually remove the $changedProperties parameter of the ColumnDiff
class.

Additionally, the following commit will mark ColumnDiff::$oldColumnName
as deprecated rendering the corresponding constructor parameter
obsolete.
@morozov morozov added this to the 3.5.0 milestone Aug 27, 2022
@morozov morozov marked this pull request as ready for review August 27, 2022 16:17
. $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);

if ($columnDiff->fromColumn !== null) {
$oldColumn = $columnDiff->fromColumn;
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be best to use oldColumn and oldColumnName as little as possible, and switch to fromColumn / fromColumnName as soon as possible (to minimize the diff between branches)

Copy link
Member Author

@morozov morozov Aug 27, 2022

Choose a reason for hiding this comment

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

I wouldn't say that the from/to naming is better than old/new (this is what GNU diff uses, for example). What diff between the branches are you referring to?

Copy link
Member

@greg0ire greg0ire Aug 27, 2022

Choose a reason for hiding this comment

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

I wouldn't say that the from/to naming is better than old/new (this is what GNU diff uses, for example).

I'm not saying it's better, but since we are using from/to as well, it might make sense to use the same naming everywhere.

What diff between the branches are you referring to?

The diff you would obtain when doing that kind of cleanup (switching to new naming) after merging up, I assumed that might have been your plan.

Copy link
Member Author

Choose a reason for hiding this comment

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

So if I understand it correctly, it's about the variable names being used in the code, not any sort of API? Please see the updated version of the patch.

The $oldColumnName property and the corresponding constructor parameter
were relevant until doctrine#220 (2.4.0)
which introduced the $fromColumn property and the corresponding
constructor parameter. Now they are redundant.

The same applies to getOldColumnName(). The $fromColumn property
contains all the properties of the old column including the name.
@morozov morozov merged commit f0235a9 into doctrine:3.5.x Aug 27, 2022
@morozov morozov deleted the schema-diff-cleanup branch August 27, 2022 17:37
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants