diff --git a/src/Platforms/PostgreSQLPlatform.php b/src/Platforms/PostgreSQLPlatform.php index c762772dee4..33ac34233ee 100644 --- a/src/Platforms/PostgreSQLPlatform.php +++ b/src/Platforms/PostgreSQLPlatform.php @@ -252,6 +252,7 @@ public function getAlterTableSQL(TableDiff $diff): array || $columnDiff->hasPrecisionChanged() || $columnDiff->hasScaleChanged() || $columnDiff->hasFixedChanged() + || $columnDiff->hasLengthChanged() ) { $type = $newColumn->getType(); diff --git a/tests/Functional/Platform/AlterColumnLengthChangeTest.php b/tests/Functional/Platform/AlterColumnLengthChangeTest.php new file mode 100644 index 00000000000..984aacc0f27 --- /dev/null +++ b/tests/Functional/Platform/AlterColumnLengthChangeTest.php @@ -0,0 +1,39 @@ +addColumn('c1', Types::STRING)->setLength(50); + + $this->dropAndCreateTable($table); + + $sm = $this->connection->createSchemaManager(); + $table = $sm->introspectTable('test_alter_length'); + $columns = $table->getColumns(); + self::assertCount(1, $columns); + self::assertSame(50, $columns[0]->getLength()); + + $table->getColumn('c1')->setLength(100); + + $diff = $sm->createComparator() + ->compareTables($sm->introspectTable('test_alter_length'), $table); + + $sm->alterTable($diff); + + $table = $sm->introspectTable('test_alter_length'); + $columns = $table->getColumns(); + + self::assertCount(1, $columns); + self::assertSame(100, $columns[0]->getLength()); + } +}