Compare commits
No commits in common. "252d398174b730cd92e2b6a3c968d0c2ae774871" and "a99bbf92e15456d03edf376bf8cd685fedbb9e13" have entirely different histories.
252d398174
...
a99bbf92e1
@ -66,49 +66,4 @@ class DatabaseUtility
|
|||||||
return GeneralUtility::makeInstance(ConnectionPool::class)
|
return GeneralUtility::makeInstance(ConnectionPool::class)
|
||||||
->getConnectionForTable($tableName);
|
->getConnectionForTable($tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* testAndCreateIndex
|
|
||||||
*/
|
|
||||||
public static function testAndCreateIndex(
|
|
||||||
$table, $indexName, $indexColumns, $type
|
|
||||||
) {
|
|
||||||
$connection = GeneralUtility::makeInstance(
|
|
||||||
ConnectionPool::class
|
|
||||||
)->getConnectionForTable($table);
|
|
||||||
$existTestQuery = "
|
|
||||||
SHOW TABLES LIKE '${table}'
|
|
||||||
";
|
|
||||||
$existTestResult = $connection
|
|
||||||
->executeQuery($existTestQuery)
|
|
||||||
->fetchAll();
|
|
||||||
if (!count($existTestResult)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$indexTestQuery = "
|
|
||||||
SHOW INDEX FROM ${table}
|
|
||||||
WHERE Key_name = '${indexName}'
|
|
||||||
";
|
|
||||||
$indexTestResult = $connection
|
|
||||||
->executeQuery($indexTestQuery)
|
|
||||||
->fetchAll();
|
|
||||||
if (count($indexTestResult)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch ($type) {
|
|
||||||
case 'btree':
|
|
||||||
$queryCreate = "
|
|
||||||
CREATE INDEX ${indexName}
|
|
||||||
USING BTREE ON ${table} (${indexColumns})
|
|
||||||
";
|
|
||||||
break;
|
|
||||||
case 'fulltext':
|
|
||||||
$queryCreate = "
|
|
||||||
CREATE FULLTEXT INDEX ${indexName}
|
|
||||||
ON ${table} (${indexColumns})
|
|
||||||
";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$connection->executeQuery($queryCreate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user