Include fulltext indexes in MySQL table create
This commit is contained in:
parent
96521f38d2
commit
692ef9c330
@ -244,6 +244,20 @@ class MysqlSchema extends Schema
|
||||
return $this->fetchQueryData($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append an SQL statement with an index definition for a full-text search
|
||||
* index over one or more columns on a table.
|
||||
*
|
||||
* @param array $statements
|
||||
* @param string $table
|
||||
* @param string $name
|
||||
* @param array $def
|
||||
*/
|
||||
function appendCreateFulltextIndex(array &$statements, $table, $name, array $def)
|
||||
{
|
||||
$statements[] = "CREATE FULLTEXT INDEX $name ON $table " . $this->buildIndexList($def);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close out a 'create table' SQL statement.
|
||||
*
|
||||
|
@ -168,17 +168,24 @@ class Schema
|
||||
}
|
||||
}
|
||||
|
||||
// Multi-value indexes are advisory and for best portability
|
||||
// should be created as separate statements.
|
||||
// Wrap the CREATE TABLE around the main body chunks...
|
||||
$statements = array();
|
||||
$statements[] = $this->startCreateTable($name, $def) . "\n" .
|
||||
implode($sql, ",\n") . "\n" .
|
||||
$this->endCreateTable($name, $def);
|
||||
|
||||
// Multi-value indexes are advisory and for best portability
|
||||
// should be created as separate statements.
|
||||
if (!empty($def['indexes'])) {
|
||||
foreach ($def['indexes'] as $col => $colDef) {
|
||||
$this->appendCreateIndex($statements, $name, $col, $colDef);
|
||||
}
|
||||
}
|
||||
if (!empty($def['fulltext indexes'])) {
|
||||
foreach ($def['fulltext indexes'] as $col => $colDef) {
|
||||
$this->appendCreateFulltextIndex($statements, $name, $col, $colDef);
|
||||
}
|
||||
}
|
||||
|
||||
return $statements;
|
||||
}
|
||||
@ -282,6 +289,20 @@ class Schema
|
||||
$statements[] = "CREATE INDEX $name ON $table " . $this->buildIndexList($def);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append an SQL statement with an index definition for a full-text search
|
||||
* index over one or more columns on a table.
|
||||
*
|
||||
* @param array $statements
|
||||
* @param string $table
|
||||
* @param string $name
|
||||
* @param array $def
|
||||
*/
|
||||
function appendCreateFulltextIndex(array &$statements, $table, $name, array $def)
|
||||
{
|
||||
throw new Exception("Fulltext index not supported in this database");
|
||||
}
|
||||
|
||||
/**
|
||||
* Append an SQL statement to drop an index from a table.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user