diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php index b851bea6c0..c79189681f 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php @@ -249,7 +249,7 @@ protected function createTableSql($name, $table) { } $sql_keys = []; - if (!empty($table['primary key']) && is_array($table['primary key'])) { + if (isset($table['primary key']) && is_array($table['primary key'])) { $sql_keys[] = 'CONSTRAINT ' . $this->ensureIdentifiersLength($name, '', 'pkey') . ' PRIMARY KEY (' . $this->createPrimaryKeySql($table['primary key']) . ')'; } if (isset($table['unique keys']) && is_array($table['unique keys'])) { @@ -542,7 +542,7 @@ public function dropTable($table) { /** * {@inheritdoc} */ - public function addField($table, $field, $spec, $keys_new = []) { + public function addField($table, $field, $spec, $new_keys = []) { if (!$this->tableExists($table)) { throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table])); } @@ -582,14 +582,14 @@ public function addField($table, $field, $spec, $keys_new = []) { if ($fixnull) { $this->connection->query("ALTER TABLE {" . $table . "} ALTER $field SET NOT NULL"); } - if (isset($keys_new)) { + if (isset($new_keys)) { // Make sure to drop the existing primary key before adding a new one. // This is only needed when adding a field because this method, unlike // changeField(), is supposed to handle primary keys automatically. - if (isset($keys_new['primary key']) && $this->constraintExists($table, 'pkey')) { + if (isset($new_keys['primary key']) && $this->constraintExists($table, 'pkey')) { $this->dropPrimaryKey($table); } - $this->_createKeys($table, $keys_new); + $this->_createKeys($table, $new_keys); } // Add column comment. if (!empty($spec['description'])) {