FIX convert index definitions to reflect actual support

It is not uncommon for an index to be defined as e.g. 'fulltext'
which SQLite3 does not support without a module to create a
virtual table (rather than an index on an existing one). The code
already in place sees that definitions be updated to 'index' on
the fly during creation and later inspection (indexList) - which
causes issue when comparing existing table definitions to what
SilverStripe expects by DataObject configuration. This discrepency
leads to tables constantly being marked to update, although
effectively nothing actually changes. We can save these CPU cycles
and a bit of head scratching by converting to a supported index type.
This commit is contained in:
NightjarNZ 2018-10-16 21:57:51 +13:00
parent 0fa6b0fde7
commit 5eacbe7842
2 changed files with 12 additions and 3 deletions

View File

@ -431,6 +431,15 @@ class SQLite3SchemaManager extends DBSchemaManager
return $this->buildSQLiteIndexName($table, $index); return $this->buildSQLiteIndexName($table, $index);
} }
protected function convertIndexSpec($indexSpec)
{
$supportedIndexTypes = ['index', 'unique'];
if (isset($indexSpec['type']) && !in_array($indexSpec['type'], $supportedIndexTypes)) {
$indexSpec['type'] = 'index';
}
return parent::convertIndexSpec($indexSpec);
}
public function indexList($table) public function indexList($table)
{ {
$indexList = array(); $indexList = array();