PostgreSQL: Offer foreign keys in create table

This commit is contained in:
Jakub Vrana
2026-01-12 07:18:15 +01:00
parent a49fcf4799
commit 3856d0563e
2 changed files with 4 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
## Adminer dev
- Pretty print JSON in edit
- PostgreSQL: Offer foreign keys in create table
- PostgreSQL: Mark unique partial indexes as unique (bug #1172)
- ClickHouse: Fix offset (bug #1188)
- ClickHouse: Fix list of tables (bug #1176)

View File

@@ -487,17 +487,19 @@ AND relnamespace = " . driver()->nsOid . "
format_type(a.atttypid, a.atttypmod) AS full_type,
pg_get_expr(d.adbin, d.adrelid) AS default,
a.attnotnull::int,
i.indrelid AS primary,
col_description(a.attrelid, a.attnum) AS comment" . (min_version(10) ? ",
a.attidentity" . (min_version(12) ? ",
a.attgenerated" : "") : "") . "
FROM pg_attribute a
LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
LEFT JOIN pg_index i ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey) AND i.indisprimary
WHERE a.attrelid = " . driver()->tableOid($table) . "
AND NOT a.attisdropped
AND a.attnum > 0
ORDER BY a.attnum") as $row
) {
//! collation, primary
//! collation
preg_match('~([^([]+)(\((.*)\))?([a-z ]+)?((\[[0-9]*])*)$~', $row["full_type"], $match);
list(, $type, $length, $row["length"], $addon, $array) = $match;
$row["length"] .= $array;