Support altering indexes
Signed-off-by: Takashi SHIRAI <shirai@nintendo.co.jp>
This commit is contained in:
parent
98458f737d
commit
ef53494df0
|
@ -370,6 +370,38 @@ ORDER BY ac.constraint_type, aic.column_position", $connection2) as $row) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function alter_indexes($table, $alter) {
|
||||||
|
$create = array();
|
||||||
|
$drop = array();
|
||||||
|
$queries = array();
|
||||||
|
foreach ($alter as $val) {
|
||||||
|
$val[2] = preg_replace('~ DESC$~', '', $val[2]);
|
||||||
|
if ($val[0] != "INDEX") {
|
||||||
|
//! descending UNIQUE indexes results in syntax error
|
||||||
|
$create[] = ($val[2] == "DROP"
|
||||||
|
? "\nDROP CONSTRAINT " . idf_escape($val[1])
|
||||||
|
: "\nADD" . ($val[1] != "" ? " CONSTRAINT " . idf_escape($val[1]) : "") . " $val[0] " . ($val[0] == "PRIMARY" ? "KEY " : "") . "(" . implode(", ", $val[2]) . ")"
|
||||||
|
);
|
||||||
|
} elseif ($val[2] == "DROP") {
|
||||||
|
$drop[] = idf_escape($val[1]);
|
||||||
|
} else {
|
||||||
|
$queries[] = "CREATE INDEX " . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table) . " (" . implode(", ", $val[2]) . ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($create) {
|
||||||
|
array_unshift($queries, "ALTER TABLE " . table($table) . implode(",", $create));
|
||||||
|
}
|
||||||
|
if ($drop) {
|
||||||
|
array_unshift($queries, "DROP INDEX " . implode(", ", $drop));
|
||||||
|
}
|
||||||
|
foreach ($queries as $query) {
|
||||||
|
if (!queries($query)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function foreign_keys($table) {
|
function foreign_keys($table) {
|
||||||
$return = array();
|
$return = array();
|
||||||
$query = "SELECT c_list.CONSTRAINT_NAME as NAME,
|
$query = "SELECT c_list.CONSTRAINT_NAME as NAME,
|
||||||
|
|
|
@ -10,6 +10,7 @@ PostgreSQL: Avoid exporting empty sequence last value (bug #768)
|
||||||
PostgreSQL: Do not show triggers from other schemas (PR #412)
|
PostgreSQL: Do not show triggers from other schemas (PR #412)
|
||||||
PostgreSQL: Fix multi-parameter functions in default values (bug #736)
|
PostgreSQL: Fix multi-parameter functions in default values (bug #736)
|
||||||
PostgreSQL PDO: Do not select NULL function for false values in edit
|
PostgreSQL PDO: Do not select NULL function for false values in edit
|
||||||
|
Oracle: Alter indexes
|
||||||
Oracle: Count tables
|
Oracle: Count tables
|
||||||
Oracle: Import from CSV
|
Oracle: Import from CSV
|
||||||
Oracle: Fix column size with string type
|
Oracle: Fix column size with string type
|
||||||
|
|
Loading…
Reference in a new issue