Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
f1a8b20a
Commit
f1a8b20a
authored
Nov 24, 2013
by
Guilherme Blanco
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #427 from deeky666/optimize-comparator-table-diff
Save one columns iteration in Comparator::diffTable
parents
25a1cced
afffd178
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+15
-15
No files found.
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
f1a8b20a
...
...
@@ -190,30 +190,30 @@ class Comparator
$table1Columns
=
$table1
->
getColumns
();
$table2Columns
=
$table2
->
getColumns
();
/
* See if all the fields in table 1 exist in table 2 */
foreach
(
$table2Columns
as
$columnName
=>
$column
)
{
if
(
!
$table1
->
hasColumn
(
$columnName
)
)
{
/
/ See if all the fields in table 1 exist in table 2.
foreach
(
$table2Columns
as
$columnName
=>
$column
)
{
if
(
!
$table1
->
hasColumn
(
$columnName
)
)
{
$tableDifferences
->
addedColumns
[
$columnName
]
=
$column
;
$changes
++
;
}
}
/* See if there are any removed fields in table 2 */
foreach
(
$table1Columns
as
$columnName
=>
$column
)
{
if
(
!
$table2
->
hasColumn
(
$columnName
)
)
{
foreach
(
$table1Columns
as
$columnName
=>
$column
)
{
// See if column is removed in table 2.
if
(
!
$table2
->
hasColumn
(
$columnName
))
{
$tableDifferences
->
removedColumns
[
$columnName
]
=
$column
;
$changes
++
;
continue
;
}
}
foreach
(
$table1Columns
as
$columnName
=>
$column
)
{
if
(
$table2
->
hasColumn
(
$columnName
)
)
{
$changedProperties
=
$this
->
diffColumn
(
$column
,
$table2
->
getColumn
(
$columnName
)
);
if
(
count
(
$changedProperties
)
)
{
$columnDiff
=
new
ColumnDiff
(
$column
->
getName
(),
$table2
->
getColumn
(
$columnName
),
$changedProperties
);
$columnDiff
->
fromColumn
=
$column
;
$tableDifferences
->
changedColumns
[
$column
->
getName
()]
=
$columnDiff
;
$changes
++
;
}
// See if column has changed properties in table 2.
$changedProperties
=
$this
->
diffColumn
(
$column
,
$table2
->
getColumn
(
$columnName
));
if
(
!
empty
(
$changedProperties
))
{
$columnDiff
=
new
ColumnDiff
(
$column
->
getName
(),
$table2
->
getColumn
(
$columnName
),
$changedProperties
);
$columnDiff
->
fromColumn
=
$column
;
$tableDifferences
->
changedColumns
[
$column
->
getName
()]
=
$columnDiff
;
$changes
++
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment