mirror of
https://github.com/vrana/adminer.git
synced 2025-08-12 17:44:07 +02:00
MS SQL export: Create foreign keys after all tables
This commit is contained in:
@@ -600,15 +600,20 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)
|
||||
$fields[] = ($index["type"] == "INDEX" ? "INDEX $name" : "CONSTRAINT $name " . ($index["type"] == "UNIQUE" ? "UNIQUE" : "PRIMARY KEY")) . " (" . implode(", ", $columns) . ")";
|
||||
}
|
||||
}
|
||||
foreach (foreign_keys($table) as $foreign) {
|
||||
$fields[] = ltrim(format_foreign_key($foreign));
|
||||
}
|
||||
foreach ($driver->checkConstraints($table) as $name => $check) {
|
||||
$fields[] = "CONSTRAINT " . idf_escape($name) . " CHECK ($check)";
|
||||
}
|
||||
return "CREATE TABLE " . table($table) . " (\n\t" . implode(",\n\t", $fields) . "\n)";
|
||||
}
|
||||
|
||||
function foreign_keys_sql($table) {
|
||||
$fields = array();
|
||||
foreach (foreign_keys($table) as $foreign) {
|
||||
$fields[] = ltrim(format_foreign_key($foreign));
|
||||
}
|
||||
return ($fields ? "ALTER TABLE " . table($table) . " ADD\n\t" . implode(",\n\t", $fields) . ";\n\n" : "");
|
||||
}
|
||||
|
||||
function truncate_sql($table) {
|
||||
return "TRUNCATE TABLE " . table($table);
|
||||
}
|
||||
|
Reference in New Issue
Block a user