From af7e9614e2d97b2bbc63dc94becc51265150e0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Tue, 13 Aug 2024 17:14:48 +0200 Subject: [PATCH] Ensure PostgreSQL field length change is executed again With #6280 quite some changes has been applied, which removed the code path to create alter sql statement if length of a field has changed. This change adds a general test for this case and reimplement the accidently removed code from the `PostgreSQLPlatform`. --- .../Platform/AlterColumnLengthChangeTest.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/Functional/Platform/AlterColumnLengthChangeTest.php 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()); + } +}