diff --git a/UPGRADE.md b/UPGRADE.md index aae5a83681e..94124f40bfd 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -744,6 +744,11 @@ The following `Comparator` methods have been marked as internal: The `diffColumn()` method has been deprecated. Use `diffTable()` instead. +## Marked `ColumnDiff` public properties as internal. + +The `$fromColumn` and `$column` properties of the `ColumnDiff` class have been marked as internal. Use the +`getOldColumn()` and `getNewColumn()` methods instead. + ## Deprecated `ColumnDiff::$changedProperties` and `::hasChanged()`. The `ColumnDiff::$changedProperties` property and the `hasChanged()` method have been deprecated. Use one of the diff --git a/src/Platforms/AbstractMySQLPlatform.php b/src/Platforms/AbstractMySQLPlatform.php index a62e07651c5..c78e0304fe0 100644 --- a/src/Platforms/AbstractMySQLPlatform.php +++ b/src/Platforms/AbstractMySQLPlatform.php @@ -324,11 +324,14 @@ public function getAlterTableSQL(TableDiff $diff): array continue; } - $columnArray = array_merge($column->toArray(), [ + $columnProperties = array_merge($column->toArray(), [ 'comment' => $column->getComment(), ]); - $queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray); + $queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL( + $column->getQuotedName($this), + $columnProperties, + ); } foreach ($diff->removedColumns as $column) { @@ -344,12 +347,16 @@ public function getAlterTableSQL(TableDiff $diff): array continue; } - $column = $columnDiff->column; - $columnArray = $column->toArray(); + $newColumn = $columnDiff->getNewColumn(); + + $newColumnProperties = array_merge($newColumn->toArray(), [ + 'comment' => $newColumn->getComment(), + ]); + + $oldColumn = $columnDiff->getOldColumn(); - $columnArray['comment'] = $column->getComment(); - $queryParts[] = 'CHANGE ' . $columnDiff->fromColumn->getQuotedName($this) . ' ' - . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray); + $queryParts[] = 'CHANGE ' . $oldColumn->getQuotedName($this) . ' ' + . $this->getColumnDeclarationSQL($newColumn->getQuotedName($this), $newColumnProperties); } foreach ($diff->renamedColumns as $oldColumnName => $column) { @@ -357,11 +364,14 @@ public function getAlterTableSQL(TableDiff $diff): array continue; } - $oldColumnName = new Identifier($oldColumnName); - $columnArray = $column->toArray(); - $columnArray['comment'] = $column->getComment(); - $queryParts[] = 'CHANGE ' . $oldColumnName->getQuotedName($this) . ' ' - . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray); + $oldColumnName = new Identifier($oldColumnName); + + $columnProperties = array_merge($column->toArray(), [ + 'comment' => $column->getComment(), + ]); + + $queryParts[] = 'CHANGE ' . $oldColumnName->getQuotedName($this) . ' ' + . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnProperties); } if (isset($diff->addedIndexes['primary'])) { @@ -635,12 +645,6 @@ public function getColumnCharsetDeclarationSQL(string $charset): string return 'CHARACTER SET ' . $charset; } - /** @internal The method should be only used from within the {@see AbstractPlatform} class hierarchy. */ - public function getColumnCollationDeclarationSQL(string $collation): string - { - return 'COLLATE ' . $this->quoteSingleIdentifier($collation); - } - /** @internal The method should be only used from within the {@see AbstractPlatform} class hierarchy. */ public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey): string { diff --git a/src/Platforms/AbstractPlatform.php b/src/Platforms/AbstractPlatform.php index a932bd77c11..e7d36bc03fb 100644 --- a/src/Platforms/AbstractPlatform.php +++ b/src/Platforms/AbstractPlatform.php @@ -1875,7 +1875,7 @@ public function getColumnCharsetDeclarationSQL(string $charset): string */ public function getColumnCollationDeclarationSQL(string $collation): string { - return $this->supportsColumnCollation() ? 'COLLATE ' . $collation : ''; + return $this->supportsColumnCollation() ? 'COLLATE ' . $this->quoteSingleIdentifier($collation) : ''; } /** diff --git a/src/Platforms/DB2Platform.php b/src/Platforms/DB2Platform.php index 0b926609175..d00cb604aeb 100644 --- a/src/Platforms/DB2Platform.php +++ b/src/Platforms/DB2Platform.php @@ -312,10 +312,11 @@ public function getAlterTableSQL(TableDiff $diff): array } if ($columnDiff->hasCommentChanged()) { + $newColumn = $columnDiff->getNewColumn(); $commentsSQL[] = $this->getCommentOnColumnSQL( $diff->getName($this)->getQuotedName($this), - $columnDiff->column->getQuotedName($this), - $columnDiff->column->getComment(), + $newColumn->getQuotedName($this), + $newColumn->getComment(), ); } @@ -409,12 +410,12 @@ private function gatherAlterColumnSQL( */ private function getAlterColumnClausesSQL(ColumnDiff $columnDiff): array { - $column = $columnDiff->column->toArray(); + $newColumn = $columnDiff->getNewColumn()->toArray(); - $alterClause = 'ALTER COLUMN ' . $columnDiff->column->getQuotedName($this); + $alterClause = 'ALTER COLUMN ' . $columnDiff->getNewColumn()->getQuotedName($this); - if ($column['columnDefinition'] !== null) { - return [$alterClause . ' ' . $column['columnDefinition']]; + if ($newColumn['columnDefinition'] !== null) { + return [$alterClause . ' ' . $newColumn['columnDefinition']]; } $clauses = []; @@ -426,16 +427,16 @@ private function getAlterColumnClausesSQL(ColumnDiff $columnDiff): array $columnDiff->hasScaleChanged() || $columnDiff->hasFixedChanged() ) { - $clauses[] = $alterClause . ' SET DATA TYPE ' . $column['type']->getSQLDeclaration($column, $this); + $clauses[] = $alterClause . ' SET DATA TYPE ' . $newColumn['type']->getSQLDeclaration($newColumn, $this); } if ($columnDiff->hasNotNullChanged()) { - $clauses[] = $column['notnull'] ? $alterClause . ' SET NOT NULL' : $alterClause . ' DROP NOT NULL'; + $clauses[] = $newColumn['notnull'] ? $alterClause . ' SET NOT NULL' : $alterClause . ' DROP NOT NULL'; } if ($columnDiff->hasDefaultChanged()) { - if (isset($column['default'])) { - $defaultClause = $this->getDefaultValueDeclarationSQL($column); + if (isset($newColumn['default'])) { + $defaultClause = $this->getDefaultValueDeclarationSQL($newColumn); if ($defaultClause !== '') { $clauses[] = $alterClause . ' SET' . $defaultClause; diff --git a/src/Platforms/OraclePlatform.php b/src/Platforms/OraclePlatform.php index 8b35c55ef52..e369ab82eb9 100644 --- a/src/Platforms/OraclePlatform.php +++ b/src/Platforms/OraclePlatform.php @@ -558,19 +558,22 @@ public function getAlterTableSQL(TableDiff $diff): array continue; } - $column = $columnDiff->column; + $newColumn = $columnDiff->getNewColumn(); + $oldColumn = $columnDiff->getOldColumn(); - $columnInfo = $column->toArray(); - $fromSQL = $this->getColumnDeclarationSQL('', $columnDiff->fromColumn->toArray()); - $currentSQL = $this->getColumnDeclarationSQL('', $columnInfo); + $newColumnProperties = $newColumn->toArray(); + $oldColumnProperties = $oldColumn->toArray(); - if ($currentSQL !== $fromSQL) { + $oldSQL = $this->getColumnDeclarationSQL('', $oldColumnProperties); + $newSQL = $this->getColumnDeclarationSQL('', $newColumnProperties); + + if ($newSQL !== $oldSQL) { if (! $columnDiff->hasNotNullChanged()) { - unset($columnInfo['notnull']); - $currentSQL = $this->getColumnDeclarationSQL('', $columnInfo); + unset($newColumnProperties['notnull']); + $newSQL = $this->getColumnDeclarationSQL('', $newColumnProperties); } - $modifyColumnSQL[] = $column->getQuotedName($this) . $currentSQL; + $modifyColumnSQL[] = $newColumn->getQuotedName($this) . $newSQL; } if (! $columnDiff->hasCommentChanged()) { @@ -579,8 +582,8 @@ public function getAlterTableSQL(TableDiff $diff): array $commentsSQL[] = $this->getCommentOnColumnSQL( $diff->getName($this)->getQuotedName($this), - $column->getQuotedName($this), - $column->getComment(), + $newColumn->getQuotedName($this), + $newColumn->getComment(), ); } diff --git a/src/Platforms/PostgreSQLPlatform.php b/src/Platforms/PostgreSQLPlatform.php index 6c6bcd56bd1..4d4fd74319e 100644 --- a/src/Platforms/PostgreSQLPlatform.php +++ b/src/Platforms/PostgreSQLPlatform.php @@ -225,15 +225,15 @@ public function getAlterTableSQL(TableDiff $diff): array $commentsSQL = []; $columnSql = []; - foreach ($diff->addedColumns as $column) { - if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) { + foreach ($diff->addedColumns as $newColumn) { + if ($this->onSchemaAlterTableAddColumn($newColumn, $diff, $columnSql)) { continue; } - $query = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray()); + $query = 'ADD ' . $this->getColumnDeclarationSQL($newColumn->getQuotedName($this), $newColumn->toArray()); $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . $query; - $comment = $column->getComment(); + $comment = $newColumn->getComment(); if ($comment === '') { continue; @@ -241,17 +241,17 @@ public function getAlterTableSQL(TableDiff $diff): array $commentsSQL[] = $this->getCommentOnColumnSQL( $diff->getName($this)->getQuotedName($this), - $column->getQuotedName($this), + $newColumn->getQuotedName($this), $comment, ); } - foreach ($diff->removedColumns as $column) { - if ($this->onSchemaAlterTableRemoveColumn($column, $diff, $columnSql)) { + foreach ($diff->removedColumns as $newColumn) { + if ($this->onSchemaAlterTableRemoveColumn($newColumn, $diff, $columnSql)) { continue; } - $query = 'DROP ' . $column->getQuotedName($this); + $query = 'DROP ' . $newColumn->getQuotedName($this); $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . $query; } @@ -260,11 +260,10 @@ public function getAlterTableSQL(TableDiff $diff): array continue; } - $fromColumn = $columnDiff->fromColumn; + $oldColumn = $columnDiff->getOldColumn(); + $newColumn = $columnDiff->getNewColumn(); - $oldColumnName = $fromColumn->getQuotedName($this); - - $column = $columnDiff->column; + $oldColumnName = $oldColumn->getQuotedName($this); if ( $columnDiff->hasTypeChanged() @@ -272,10 +271,10 @@ public function getAlterTableSQL(TableDiff $diff): array || $columnDiff->hasScaleChanged() || $columnDiff->hasFixedChanged() ) { - $type = $column->getType(); + $type = $newColumn->getType(); // SERIAL/BIGSERIAL are not "real" types and we can't alter a column to that type - $columnDefinition = $column->toArray(); + $columnDefinition = $newColumn->toArray(); $columnDefinition['autoincrement'] = false; // here was a server version check before, but DBAL API does not support this anymore. @@ -284,20 +283,21 @@ public function getAlterTableSQL(TableDiff $diff): array } if ($columnDiff->hasDefaultChanged()) { - $defaultClause = $column->getDefault() === null + $defaultClause = $newColumn->getDefault() === null ? ' DROP DEFAULT' - : ' SET' . $this->getDefaultValueDeclarationSQL($column->toArray()); - $query = 'ALTER ' . $oldColumnName . $defaultClause; - $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . $query; + : ' SET' . $this->getDefaultValueDeclarationSQL($newColumn->toArray()); + + $query = 'ALTER ' . $oldColumnName . $defaultClause; + $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . $query; } if ($columnDiff->hasNotNullChanged()) { - $query = 'ALTER ' . $oldColumnName . ' ' . ($column->getNotnull() ? 'SET' : 'DROP') . ' NOT NULL'; + $query = 'ALTER ' . $oldColumnName . ' ' . ($newColumn->getNotnull() ? 'SET' : 'DROP') . ' NOT NULL'; $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . $query; } if ($columnDiff->hasAutoIncrementChanged()) { - if ($column->getAutoincrement()) { + if ($newColumn->getAutoincrement()) { $query = 'ADD GENERATED BY DEFAULT AS IDENTITY'; } else { $query = 'DROP IDENTITY'; @@ -307,13 +307,13 @@ public function getAlterTableSQL(TableDiff $diff): array . ' ALTER ' . $oldColumnName . ' ' . $query; } - $newComment = $column->getComment(); - $oldComment = $columnDiff->fromColumn->getComment(); + $newComment = $newColumn->getComment(); + $oldComment = $columnDiff->getOldColumn()->getComment(); if ($columnDiff->hasCommentChanged() || $oldComment !== $newComment) { $commentsSQL[] = $this->getCommentOnColumnSQL( $diff->getName($this)->getQuotedName($this), - $column->getQuotedName($this), + $newColumn->getQuotedName($this), $newComment, ); } @@ -323,7 +323,7 @@ public function getAlterTableSQL(TableDiff $diff): array } $query = 'ALTER ' . $oldColumnName . ' TYPE ' - . $column->getType()->getSQLDeclaration($column->toArray(), $this); + . $newColumn->getType()->getSQLDeclaration($newColumn->toArray(), $this); $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . $query; } @@ -796,12 +796,6 @@ public function supportsColumnCollation(): bool return true; } - /** @internal The method should be only used from within the {@see AbstractPlatform} class hierarchy. */ - public function getColumnCollationDeclarationSQL(string $collation): string - { - return 'COLLATE ' . $this->quoteSingleIdentifier($collation); - } - /** * {@inheritdoc} */ diff --git a/src/Platforms/SQLServerPlatform.php b/src/Platforms/SQLServerPlatform.php index 7860dae9e84..ae974995164 100644 --- a/src/Platforms/SQLServerPlatform.php +++ b/src/Platforms/SQLServerPlatform.php @@ -363,12 +363,14 @@ public function getAlterTableSQL(TableDiff $diff): array continue; } - $columnDef = $column->toArray(); - $addColumnSql = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnDef); - if (isset($columnDef['default'])) { + $columnProperties = $column->toArray(); + + $addColumnSql = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnProperties); + + if (isset($columnProperties['default'])) { $addColumnSql .= ' CONSTRAINT ' . $this->generateDefaultConstraintName($diff->name, $column->getQuotedName($this)) . - $this->getDefaultValueDeclarationSQL($columnDef); + $this->getDefaultValueDeclarationSQL($columnProperties); } $queryParts[] = $addColumnSql; @@ -399,25 +401,34 @@ public function getAlterTableSQL(TableDiff $diff): array continue; } - $column = $columnDiff->column; - $comment = $column->getComment(); - $hasComment = $comment !== ''; + $newColumn = $columnDiff->getNewColumn(); + $newComment = $newColumn->getComment(); + $hasNewComment = $newComment !== ''; - $fromComment = $columnDiff->fromColumn->getComment(); - $hasFromComment = $fromComment !== ''; + $oldColumn = $columnDiff->getOldColumn(); + $oldComment = $oldColumn->getComment(); + $hasOldComment = $oldComment !== ''; - if ($hasFromComment && $hasComment && $fromComment !== $comment) { - $commentsSql[] = $this->getAlterColumnCommentSQL($diff->name, $column->getQuotedName($this), $comment); - } elseif ($hasFromComment && ! $hasComment) { - $commentsSql[] = $this->getDropColumnCommentSQL($diff->name, $column->getQuotedName($this)); - } elseif (! $hasFromComment && $hasComment) { - $commentsSql[] = $this->getCreateColumnCommentSQL($diff->name, $column->getQuotedName($this), $comment); + if ($hasOldComment && $hasNewComment && $newComment !== $oldComment) { + $commentsSql[] = $this->getAlterColumnCommentSQL( + $diff->name, + $newColumn->getQuotedName($this), + $newComment, + ); + } elseif ($hasOldComment && ! $hasNewComment) { + $commentsSql[] = $this->getDropColumnCommentSQL($diff->name, $newColumn->getQuotedName($this)); + } elseif (! $hasOldComment && $hasNewComment) { + $commentsSql[] = $this->getCreateColumnCommentSQL( + $diff->name, + $newColumn->getQuotedName($this), + $newComment + ); } - $columnNameSQL = $column->getQuotedName($this); + $columnNameSQL = $newColumn->getQuotedName($this); - $oldDeclarationSQL = $this->getColumnDeclarationSQL($columnNameSQL, $columnDiff->fromColumn->toArray()); - $newDeclarationSQL = $this->getColumnDeclarationSQL($columnNameSQL, $column->toArray()); + $oldDeclarationSQL = $this->getColumnDeclarationSQL($columnNameSQL, $oldColumn->toArray()); + $newDeclarationSQL = $this->getColumnDeclarationSQL($columnNameSQL, $newColumn->toArray()); $declarationSQLChanged = $newDeclarationSQL !== $oldDeclarationSQL; $defaultChanged = $columnDiff->hasDefaultChanged(); @@ -431,7 +442,7 @@ public function getAlterTableSQL(TableDiff $diff): array if ($requireDropDefaultConstraint) { $queryParts[] = $this->getAlterTableDropDefaultConstraintClause( $diff->name, - $columnDiff->fromColumn->getName(), + $oldColumn->getName(), ); } @@ -440,36 +451,36 @@ public function getAlterTableSQL(TableDiff $diff): array } if ( - $column->getDefault() === null + $newColumn->getDefault() === null || (! $requireDropDefaultConstraint && ! $defaultChanged) ) { continue; } - $queryParts[] = $this->getAlterTableAddDefaultConstraintClause($diff->name, $column); + $queryParts[] = $this->getAlterTableAddDefaultConstraintClause($diff->name, $newColumn); } - foreach ($diff->renamedColumns as $fromColumnName => $column) { - if ($this->onSchemaAlterTableRenameColumn($fromColumnName, $column, $diff, $columnSql)) { + foreach ($diff->renamedColumns as $oldColumnName => $newColumn) { + if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $newColumn, $diff, $columnSql)) { continue; } - $fromColumnName = new Identifier($fromColumnName); + $oldColumnName = new Identifier($oldColumnName); $sql[] = "sp_rename '" . - $diff->getName($this)->getQuotedName($this) . '.' . $fromColumnName->getQuotedName($this) . - "', '" . $column->getQuotedName($this) . "', 'COLUMN'"; + $diff->getName($this)->getQuotedName($this) . '.' . $oldColumnName->getQuotedName($this) . + "', '" . $newColumn->getQuotedName($this) . "', 'COLUMN'"; // Recreate default constraint with new column name if necessary (for future reference). - if ($column->getDefault() === null) { + if ($newColumn->getDefault() === null) { continue; } $queryParts[] = $this->getAlterTableDropDefaultConstraintClause( $diff->name, - $fromColumnName->getQuotedName($this), + $oldColumnName->getQuotedName($this), ); - $queryParts[] = $this->getAlterTableAddDefaultConstraintClause($diff->name, $column); + $queryParts[] = $this->getAlterTableAddDefaultConstraintClause($diff->name, $newColumn); } $tableSql = []; @@ -553,7 +564,7 @@ private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff { // We only need to drop an existing default constraint if we know the // column was defined with a default value before. - if ($columnDiff->fromColumn->getDefault() === null) { + if ($columnDiff->getOldColumn()->getDefault() === null) { return false; } @@ -1192,6 +1203,14 @@ public function getColumnDeclarationSQL(string $name, array $column): string return $name . ' ' . $columnDef; } + /** + * SQL Server does not support quoting collation identifiers. + */ + public function getColumnCollationDeclarationSQL(string $collation): string + { + return 'COLLATE ' . $collation; + } + public function columnsEqual(Column $column1, Column $column2): bool { if (! parent::columnsEqual($column1, $column2)) { diff --git a/src/Platforms/SQLitePlatform.php b/src/Platforms/SQLitePlatform.php index 0307dfb8f3e..b8e04fe1153 100644 --- a/src/Platforms/SQLitePlatform.php +++ b/src/Platforms/SQLitePlatform.php @@ -19,6 +19,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types; +use Doctrine\DBAL\Types\IntegerType; use function array_combine; use function array_keys; @@ -632,13 +633,14 @@ public function getAlterTableSQL(TableDiff $diff): array } $oldColumnName = strtolower($oldColumnName); - $columns = $this->replaceColumn($diff->name, $columns, $oldColumnName, $columnDiff->column); + $newColumn = $columnDiff->getNewColumn(); + $columns = $this->replaceColumn($diff->name, $columns, $oldColumnName, $newColumn); if (! isset($newColumnNames[$oldColumnName])) { continue; } - $newColumnNames[$oldColumnName] = $columnDiff->column->getQuotedName($this); + $newColumnNames[$oldColumnName] = $newColumn->getQuotedName($this); } foreach ($diff->addedColumns as $columnName => $column) { @@ -737,10 +739,9 @@ private function getSimpleAlterTableSQL(TableDiff $diff): array|false { // Suppress changes on integer type autoincrement columns. foreach ($diff->changedColumns as $oldColumnName => $columnDiff) { - if ( - ! $columnDiff->column->getAutoincrement() || - ! $columnDiff->column->getType() instanceof Types\IntegerType - ) { + $newColumn = $columnDiff->getNewColumn(); + + if (! $newColumn->getAutoincrement() || ! $newColumn->getType() instanceof IntegerType) { continue; } @@ -750,7 +751,8 @@ private function getSimpleAlterTableSQL(TableDiff $diff): array|false continue; } - $fromColumnType = $columnDiff->fromColumn->getType(); + $fromColumnType = $columnDiff->getOldColumn() + ->getType(); if (! ($fromColumnType instanceof Types\SmallIntType) && ! ($fromColumnType instanceof Types\BigIntType)) { continue; @@ -845,9 +847,9 @@ private function getColumnNamesInAlteredTable(TableDiff $diff, Table $fromTable) } foreach ($diff->changedColumns as $oldColumnName => $columnDiff) { - $columnName = $columnDiff->column->getName(); - $columns[strtolower($oldColumnName)] = $columnName; - $columns[strtolower($columnName)] = $columnName; + $newColumnName = $columnDiff->getNewColumn()->getName(); + $columns[strtolower($oldColumnName)] = $newColumnName; + $columns[strtolower($newColumnName)] = $newColumnName; } foreach ($diff->addedColumns as $column) { diff --git a/src/Schema/ColumnDiff.php b/src/Schema/ColumnDiff.php index d770f4040a3..1e7f58a6cc1 100644 --- a/src/Schema/ColumnDiff.php +++ b/src/Schema/ColumnDiff.php @@ -16,6 +16,16 @@ public function __construct(public Column $column, public Column $fromColumn) { } + public function getOldColumn(): Column + { + return $this->fromColumn; + } + + public function getNewColumn(): Column + { + return $this->column; + } + public function hasTypeChanged(): bool { return $this->column->getType()::class !== $this->fromColumn->getType()::class; diff --git a/src/Schema/SQLiteSchemaManager.php b/src/Schema/SQLiteSchemaManager.php index 1e7186ab567..37078dbbe1f 100644 --- a/src/Schema/SQLiteSchemaManager.php +++ b/src/Schema/SQLiteSchemaManager.php @@ -56,14 +56,6 @@ protected function fetchForeignKeyColumnsByTable(string $databaseName): array return $columnsByTable; } - public function renameTable(string $name, string $newName): void - { - $tableDiff = new TableDiff($name); - $tableDiff->fromTable = $this->introspectTable($name); - $tableDiff->newName = $newName; - $this->alterTable($tableDiff); - } - public function createForeignKey(ForeignKeyConstraint $foreignKey, string $table): void { $table = $this->introspectTable($table); diff --git a/tests/Functional/Schema/OracleSchemaManagerTest.php b/tests/Functional/Schema/OracleSchemaManagerTest.php index 77e0d14732a..9170dcf1810 100644 --- a/tests/Functional/Schema/OracleSchemaManagerTest.php +++ b/tests/Functional/Schema/OracleSchemaManagerTest.php @@ -25,17 +25,6 @@ protected function supportsPlatform(AbstractPlatform $platform): bool return $platform instanceof OraclePlatform; } - public function testRenameTable(): void - { - $this->createTestTable('list_tables_test'); - $this->dropTableIfExists('list_tables_test_new_name'); - $this->schemaManager->renameTable('list_tables_test', 'list_tables_test_new_name'); - - $tables = $this->schemaManager->listTables(); - - self::assertHasTable($tables); - } - /** * Oracle currently stores VARBINARY columns as RAW (fixed-size) */ diff --git a/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php index 867798ebf6b..579666949fd 100644 --- a/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -239,6 +239,15 @@ public static function tableFilterProvider(): iterable yield 'Two tables' => ['filter_test_', 2]; } + public function testRenameTable(): void + { + $this->createTestTable('old_name'); + $this->schemaManager->renameTable('old_name', 'new_name'); + + self::assertFalse($this->schemaManager->tablesExist(['old_name'])); + self::assertTrue($this->schemaManager->tablesExist(['new_name'])); + } + public function createListTableColumns(): Table { $table = new Table('list_table_columns'); diff --git a/tests/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Functional/Schema/SqliteSchemaManagerTest.php index 71ff3775f9c..75d41a50a1e 100644 --- a/tests/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Functional/Schema/SqliteSchemaManagerTest.php @@ -32,16 +32,6 @@ public function testListDatabases(): void $this->schemaManager->listDatabases(); } - public function testRenameTable(): void - { - $this->createTestTable('oldname'); - $this->schemaManager->renameTable('oldname', 'newname'); - - $tables = $this->schemaManager->listTableNames(); - self::assertContains('newname', $tables); - self::assertNotContains('oldname', $tables); - } - public function createListTableColumns(): Table { $table = parent::createListTableColumns(); diff --git a/tests/Platforms/SQLitePlatformTest.php b/tests/Platforms/SQLitePlatformTest.php index 19074c98463..c054fbd4b0a 100644 --- a/tests/Platforms/SQLitePlatformTest.php +++ b/tests/Platforms/SQLitePlatformTest.php @@ -655,14 +655,6 @@ public function testSupportsColumnCollation(): void self::assertTrue($this->platform->supportsColumnCollation()); } - public function testColumnCollationDeclarationSQL(): void - { - self::assertSame( - 'COLLATE NOCASE', - $this->platform->getColumnCollationDeclarationSQL('NOCASE'), - ); - } - public function testGetCreateTableSQLWithColumnCollation(): void { $table = new Table('foo'); @@ -672,7 +664,7 @@ public function testGetCreateTableSQLWithColumnCollation(): void self::assertSame( [ 'CREATE TABLE foo (no_collation VARCHAR(255) NOT NULL, ' - . 'column_collation VARCHAR(255) NOT NULL COLLATE NOCASE)', + . 'column_collation VARCHAR(255) NOT NULL COLLATE "NOCASE")', ], $this->platform->getCreateTableSQL($table), );