diff --git a/src/Platforms/PostgreSQLPlatform.php b/src/Platforms/PostgreSQLPlatform.php index 945cc7afa84..b4ec3ff4a4a 100644 --- a/src/Platforms/PostgreSQLPlatform.php +++ b/src/Platforms/PostgreSQLPlatform.php @@ -199,7 +199,7 @@ public function supportsPartialIndexes() */ public function usesSequenceEmulatedIdentityColumns() { - return true; + return false; } /** @@ -413,7 +413,8 @@ public function getListTableColumnsSQL($table, $database = null) ) AS default, (SELECT pg_description.description FROM pg_description WHERE pg_description.objoid = c.oid AND a.attnum = pg_description.objsubid - ) AS comment + ) AS comment, + a.attidentity AS identity FROM pg_attribute a, pg_class c, pg_type t, pg_namespace n WHERE " . $this->getTableWhereClause($table, 'c', 'n') . ' AND a.attnum > 0 @@ -920,7 +921,7 @@ public function getBooleanTypeDeclarationSQL(array $column) public function getIntegerTypeDeclarationSQL(array $column) { if (! empty($column['autoincrement'])) { - return 'SERIAL'; + return 'INT GENERATED ALWAYS AS IDENTITY'; } return 'INT'; diff --git a/src/Schema/PostgreSQLSchemaManager.php b/src/Schema/PostgreSQLSchemaManager.php index 03239bde5c2..bb9bd01d907 100644 --- a/src/Schema/PostgreSQLSchemaManager.php +++ b/src/Schema/PostgreSQLSchemaManager.php @@ -366,7 +366,9 @@ protected function _getPortableTableColumnDefinition($tableColumn) $autoincrement = false; - if ( + if (in_array($tableColumn['identity'], ['a', 'd'])) { + $autoincrement = true; + } elseif ( $tableColumn['default'] !== null && preg_match("/^nextval\('(.*)'(::.*)?\)$/", $tableColumn['default'], $matches) === 1 ) {