mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
BUGFIX: Prevent dev/build errors with fulltext indexes on MSSQL.
This commit is contained in:
parent
feebe26208
commit
9a1ee37cbd
@ -421,10 +421,18 @@ class MSSQLDatabase extends SS_Database {
|
|||||||
$indexList = $this->indexList($tableName);
|
$indexList = $this->indexList($tableName);
|
||||||
|
|
||||||
if($newFields) foreach($newFields as $k => $v) $alterList[] .= "ALTER TABLE \"$tableName\" ADD \"$k\" $v";
|
if($newFields) foreach($newFields as $k => $v) $alterList[] .= "ALTER TABLE \"$tableName\" ADD \"$k\" $v";
|
||||||
if($alteredFields) foreach($alteredFields as $k => $v) {
|
|
||||||
|
if($alteredFields) {
|
||||||
|
// fulltext indexes need to be dropped if alterting a table
|
||||||
|
if($this->fulltextIndexExists($tableName) === true) {
|
||||||
|
$alterList[] = "\nDROP FULLTEXT INDEX ON \"$tableName\";";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($alteredFields as $k => $v) {
|
||||||
$val = $this->alterTableAlterColumn($tableName, $k, $v, $indexList);
|
$val = $this->alterTableAlterColumn($tableName, $k, $v, $indexList);
|
||||||
if($val != '') $alterList[] .= $val;
|
if($val != '') $alterList[] .= $val;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($alteredIndexes) foreach($alteredIndexes as $k => $v) $alterList[] .= $this->getIndexSqlDefinition($tableName, $k, $v);
|
if($alteredIndexes) foreach($alteredIndexes as $k => $v) $alterList[] .= $this->getIndexSqlDefinition($tableName, $k, $v);
|
||||||
if($newIndexes) foreach($newIndexes as $k =>$v) $alterList[] .= $this->getIndexSqlDefinition($tableName, $k, $v);
|
if($newIndexes) foreach($newIndexes as $k =>$v) $alterList[] .= $this->getIndexSqlDefinition($tableName, $k, $v);
|
||||||
@ -505,11 +513,6 @@ class MSSQLDatabase extends SS_Database {
|
|||||||
$alterCol = "\nDROP INDEX \"$indexName\" ON \"$tableName\";";
|
$alterCol = "\nDROP INDEX \"$indexName\" ON \"$tableName\";";
|
||||||
}
|
}
|
||||||
|
|
||||||
// fulltext indexes need to be dropped if alterting a table
|
|
||||||
if($this->fulltextIndexExists($tableName) === true) {
|
|
||||||
$alterCol .= "\nDROP FULLTEXT INDEX ON \"$tableName\";";
|
|
||||||
}
|
|
||||||
|
|
||||||
$prefix="ALTER TABLE \"" . $tableName . "\" ";
|
$prefix="ALTER TABLE \"" . $tableName . "\" ";
|
||||||
|
|
||||||
// Remove the old default prior to adjusting the column.
|
// Remove the old default prior to adjusting the column.
|
||||||
@ -727,12 +730,7 @@ class MSSQLDatabase extends SS_Database {
|
|||||||
|
|
||||||
$primary_key=$this->getPrimaryKey($tableName);
|
$primary_key=$this->getPrimaryKey($tableName);
|
||||||
|
|
||||||
$drop = '';
|
return "CREATE FULLTEXT INDEX ON \"$tableName\" ({$indexSpec['value']}) KEY INDEX $primary_key WITH CHANGE_TRACKING AUTO;";
|
||||||
if($this->fulltextIndexExists($tableName) === true) {
|
|
||||||
$drop = "DROP FULLTEXT INDEX ON \"$tableName\";";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $drop . "CREATE FULLTEXT INDEX ON \"$tableName\" ({$indexSpec['value']}) KEY INDEX $primary_key WITH CHANGE_TRACKING AUTO;";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user