Commit 79303bb8 authored by Benni Mack's avatar Benni Mack
Browse files

[BUGFIX] Revert "Recognize removed columns on PostgreSQL"

This change reverts commit 154606e3
as this introduced some behavior related to DBMS (postgres, mssql)
which our test suite found.

Change-Id: I6513f76f537c04e4ebe06cae4a475c5d8d7fbbf8
Resolves: #93568
Reverts: #93491
Releases: master, 10.4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68072

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent abe62183
......@@ -21,7 +21,6 @@ use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform as PostgreSqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform as SQLServerPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
......@@ -717,7 +716,7 @@ class ConnectionMigrator
continue;
}
$databasePlatform = $this->getDatabasePlatform($index);
$isSqlite = $this->tableRunsOnSqlite($index);
// Treat each changed column with a new diff to get a dedicated suggestions
// just for this single column.
......@@ -727,7 +726,7 @@ class ConnectionMigrator
continue;
}
$renameColumnTableDiff = GeneralUtility::makeInstance(
$changedTables[$index . ':' . $changedColumn->column->getName()] = GeneralUtility::makeInstance(
TableDiff::class,
$changedTable->name,
[],
......@@ -738,12 +737,7 @@ class ConnectionMigrator
[],
$this->buildQuotedTable($schemaDiff->fromSchema->getTable($changedTable->name))
);
if ($databasePlatform === 'postgresql') {
$renameColumnTableDiff->renamedColumns[$oldFieldName] = $changedColumn->column;
}
$changedTables[$index . ':' . $changedColumn->column->getName()] = $renameColumnTableDiff;
if ($databasePlatform === 'sqlite') {
if ($isSqlite) {
break;
}
}
......@@ -781,7 +775,7 @@ class ConnectionMigrator
foreach ($schemaDiff->changedTables as $index => $changedTable) {
$fromTable = $this->buildQuotedTable($schemaDiff->fromSchema->getTable($changedTable->name));
$isSqlite = $this->getDatabasePlatform($index) === 'sqlite';
$isSqlite = $this->tableRunsOnSqlite($index);
$addMoreOperations = true;
if (count($changedTable->removedColumns) !== 0) {
......@@ -1336,19 +1330,9 @@ class ConnectionMigrator
);
}
protected function getDatabasePlatform(string $tableName): string
protected function tableRunsOnSqlite(string $tableName): bool
{
$databasePlatform = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($tableName)->getDatabasePlatform();
if ($databasePlatform instanceof PostgreSqlPlatform) {
return 'postgresql';
}
if ($databasePlatform instanceof SQLServerPlatform) {
return 'mssql';
}
if ($databasePlatform instanceof SqlitePlatform) {
return 'sqlite';
}
return 'mysql';
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($tableName);
return $connection->getDatabasePlatform() instanceof SqlitePlatform;
}
}
......@@ -203,6 +203,9 @@ class SchemaMigratorTest extends FunctionalTestCase
/**
* @test
* @group not-postgres
* @group not-mssql
* @group not-sqlite
*/
public function renameUnusedField()
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment