mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
Table alterations refactored
This commit is contained in:
parent
59d4622bc7
commit
1964ac5907
@ -251,7 +251,7 @@ class MSSQLDatabase extends Database {
|
||||
$fieldSchemas = $indexSchemas = "";
|
||||
|
||||
$alterList = array();
|
||||
if($newFields) foreach($newFields as $k => $v) $alterList[] .= "ADD \"$k\" $v";
|
||||
if($newFields) foreach($newFields as $k => $v) $alterList[] .= "ALTER TABLE \"$tableName\" ADD \"$k\" $v";
|
||||
|
||||
$indexList=$this->IndexList($tableName);
|
||||
|
||||
@ -289,7 +289,9 @@ class MSSQLDatabase extends Database {
|
||||
|
||||
if($alterList) {
|
||||
foreach($alterList as $this_alteration){
|
||||
$this->query("ALTER TABLE \"$tableName\" $this_alteration;");
|
||||
if($this_alteration!=''){
|
||||
$this->query($this_alteration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,7 +351,7 @@ class MSSQLDatabase extends Database {
|
||||
//drop the index if it exists:
|
||||
$alterCol='';
|
||||
if(isset($indexList[$colName])){
|
||||
$alterCol = "\nDROP INDEX \"$tableName\".ix_{$tableName}_{$colName}";
|
||||
$alterCol = "\nDROP INDEX \"$tableName\".ix_{$tableName}_{$colName};";
|
||||
}
|
||||
|
||||
$prefix="ALTER TABLE \"" . $tableName . "\" ";
|
||||
|
Loading…
Reference in New Issue
Block a user