1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-14 02:23:59 +02:00

PostgreSQL: Export DROP SEQUENCE if dropping table

This commit is contained in:
Jakub Vrana
2018-01-22 14:33:21 +01:00
parent eee9a62c8f
commit 993dce398d
5 changed files with 8 additions and 5 deletions

View File

@@ -617,7 +617,7 @@ AND typelem = 0"
return $return;
}
function create_sql($table, $auto_increment) {
function create_sql($table, $auto_increment, $style) {
global $connection;
$return = '';
$return_parts = array();
@@ -647,7 +647,8 @@ AND typelem = 0"
if (preg_match('~nextval\(\'([^\']+)\'\)~', $field['default'], $matches)) {
$sequence_name = $matches[1];
$sq = reset(get_rows("SELECT * FROM $sequence_name"));
$sequences[] = "CREATE SEQUENCE $sequence_name INCREMENT $sq[increment_by] MINVALUE $sq[min_value] MAXVALUE $sq[max_value] START " . ($auto_increment ? $sq['last_value'] : 1) . " CACHE $sq[cache_value];";
$sequences[] = ($style == "DROP+CREATE" ? "DROP SEQUENCE $sequence_name;\n" : "")
. "CREATE SEQUENCE $sequence_name INCREMENT $sq[increment_by] MINVALUE $sq[min_value] MAXVALUE $sq[max_value] START " . ($auto_increment ? $sq['last_value'] : 1) . " CACHE $sq[cache_value];";
}
}