Skip to content

Commit

Permalink
Rename parameters of the diff-related methods
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Oct 16, 2022
1 parent aae1184 commit fc39724
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 133 deletions.
6 changes: 3 additions & 3 deletions src/Platforms/MySQL/Comparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public function __construct(
parent::__construct($platform);
}

public function diffTable(Table $fromTable, Table $toTable): ?TableDiff
public function diffTable(Table $oldTable, Table $newTable): ?TableDiff
{
return parent::diffTable(
$this->normalizeTable($fromTable),
$this->normalizeTable($toTable),
$this->normalizeTable($oldTable),
$this->normalizeTable($newTable),
);
}

Expand Down
12 changes: 6 additions & 6 deletions src/Platforms/SQLServer/Comparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public function __construct(SQLServerPlatform $platform, private readonly string
parent::__construct($platform);
}

public function diffTable(Table $fromTable, Table $toTable): ?TableDiff
public function diffTable(Table $oldTable, Table $newTable): ?TableDiff
{
$fromTable = clone $fromTable;
$toTable = clone $toTable;
$oldTable = clone $oldTable;
$newTable = clone $newTable;

$this->normalizeColumns($fromTable);
$this->normalizeColumns($toTable);
$this->normalizeColumns($oldTable);
$this->normalizeColumns($newTable);

return parent::diffTable($fromTable, $toTable);
return parent::diffTable($oldTable, $newTable);
}

private function normalizeColumns(Table $table): void
Expand Down
12 changes: 6 additions & 6 deletions src/Platforms/SQLite/Comparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public function __construct(SQLitePlatform $platform)
parent::__construct($platform);
}

public function diffTable(Table $fromTable, Table $toTable): ?TableDiff
public function diffTable(Table $oldTable, Table $newTable): ?TableDiff
{
$fromTable = clone $fromTable;
$toTable = clone $toTable;
$oldTable = clone $oldTable;
$newTable = clone $newTable;

$this->normalizeColumns($fromTable);
$this->normalizeColumns($toTable);
$this->normalizeColumns($oldTable);
$this->normalizeColumns($newTable);

return parent::diffTable($fromTable, $toTable);
return parent::diffTable($oldTable, $newTable);
}

private function normalizeColumns(Table $table): void
Expand Down
20 changes: 10 additions & 10 deletions src/Platforms/SQLitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,11 @@ private function getSimpleAlterTableSQL(TableDiff $diff): array|false
}

/** @return string[] */
private function getColumnNamesInAlteredTable(TableDiff $diff, Table $fromTable): array
private function getColumnNamesInAlteredTable(TableDiff $diff, Table $oldTable): array
{
$columns = [];

foreach ($fromTable->getColumns() as $column) {
foreach ($oldTable->getColumns() as $column) {
$columnName = $column->getName();
$columns[strtolower($columnName)] = $columnName;
}
Expand Down Expand Up @@ -825,10 +825,10 @@ private function getColumnNamesInAlteredTable(TableDiff $diff, Table $fromTable)
}

/** @return Index[] */
private function getIndexesInAlteredTable(TableDiff $diff, Table $fromTable): array
private function getIndexesInAlteredTable(TableDiff $diff, Table $oldTable): array
{
$indexes = $fromTable->getIndexes();
$columnNames = $this->getColumnNamesInAlteredTable($diff, $fromTable);
$indexes = $oldTable->getIndexes();
$columnNames = $this->getColumnNamesInAlteredTable($diff, $oldTable);

foreach ($indexes as $key => $index) {
foreach ($diff->getRenamedIndexes() as $oldIndexName => $renamedIndex) {
Expand Down Expand Up @@ -899,10 +899,10 @@ private function getIndexesInAlteredTable(TableDiff $diff, Table $fromTable): ar
}

/** @return ForeignKeyConstraint[] */
private function getForeignKeysInAlteredTable(TableDiff $diff, Table $fromTable): array
private function getForeignKeysInAlteredTable(TableDiff $diff, Table $oldTable): array
{
$foreignKeys = $fromTable->getForeignKeys();
$columnNames = $this->getColumnNamesInAlteredTable($diff, $fromTable);
$foreignKeys = $oldTable->getForeignKeys();
$columnNames = $this->getColumnNamesInAlteredTable($diff, $oldTable);

foreach ($foreignKeys as $key => $constraint) {
$changed = false;
Expand Down Expand Up @@ -959,11 +959,11 @@ private function getForeignKeysInAlteredTable(TableDiff $diff, Table $fromTable)
}

/** @return Index[] */
private function getPrimaryIndexInAlteredTable(TableDiff $diff, Table $fromTable): array
private function getPrimaryIndexInAlteredTable(TableDiff $diff, Table $oldTable): array
{
$primaryIndex = [];

foreach ($this->getIndexesInAlteredTable($diff, $fromTable) as $index) {
foreach ($this->getIndexesInAlteredTable($diff, $oldTable) as $index) {
if (! $index->isPrimary()) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,10 @@ public function alterSchema(SchemaDiff $schemaDiff): void
*
* @throws Exception
*/
public function migrateSchema(Schema $toSchema): void
public function migrateSchema(Schema $newSchema): void
{
$schemaDiff = $this->createComparator()
->compareSchemas($this->introspectSchema(), $toSchema);
->compareSchemas($this->introspectSchema(), $newSchema);

$this->alterSchema($schemaDiff);
}
Expand Down
Loading

0 comments on commit fc39724

Please sign in to comment.