PostgreSQL: Create PRIMARY KEY for auto increment columns

This commit is contained in:
Jakub Vrana 2021-02-08 14:00:38 +01:00
parent d4f7e04156
commit 9e74c0632f
2 changed files with 8 additions and 4 deletions

View file

@ -491,7 +491,7 @@ ORDER BY connamespace, conname") as $row) {
}
function auto_increment() {
return (min_version(11) ? " PRIMARY KEY" : "");
return "";
}
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
@ -508,11 +508,14 @@ ORDER BY connamespace, conname") as $row) {
} else {
$val5 = $val[5];
unset($val[5]);
if (isset($val[6]) && $field[0] == "") { // auto_increment
$val[1] = ($val[1] == " bigint" ? " big" : ($val[1] == " smallint" ? " small" : " ")) . "serial";
}
if ($field[0] == "") {
if (isset($val[6])) { // auto_increment
$val[1] = ($val[1] == " bigint" ? " big" : ($val[1] == " smallint" ? " small" : " ")) . "serial";
}
$alter[] = ($table != "" ? "ADD " : " ") . implode($val);
if (isset($val[6])) {
$alter[] = ($table != "" ? "ADD" : " ") . " PRIMARY KEY ($val[0])";
}
} else {
if ($column != $val[0]) {
$queries[] = "ALTER TABLE " . table($name) . " RENAME $column TO $val[0]";

View file

@ -3,6 +3,7 @@ Skip date columns for non-date values in search anywhere
Add DB version to comment in export
Support PHP 8 in create table (regression from 4.7.9)
MySQL 8: Fix EXPLAIN in SQL command
PostgreSQL: Create PRIMARY KEY for auto increment columns
PostgreSQL PDO: Do not select NULL function for false values in edit
Adminer 4.7.9 (released 2021-02-07):