Automatically add or drop fulltext indexes
This commit is contained in:
parent
5b0192a8ac
commit
48625da04b
@ -87,7 +87,7 @@ class Notice extends Managed_DataObject
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
return array(
|
||||
$def = array(
|
||||
'fields' => array(
|
||||
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
|
||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'who made the update'),
|
||||
@ -129,6 +129,12 @@ class Notice extends Managed_DataObject
|
||||
'notice_repeatof_idx' => array('repeat_of'),
|
||||
)
|
||||
);
|
||||
|
||||
if (common_config('search', 'type') == 'fulltext') {
|
||||
$def['fulltext indexes'] = array('content' => array('content'));
|
||||
}
|
||||
|
||||
return $def;
|
||||
}
|
||||
|
||||
function multiGet($kc, $kvs, $skipNulls=true)
|
||||
|
@ -51,7 +51,7 @@ class Profile extends Managed_DataObject
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
return array(
|
||||
$def = array(
|
||||
'description' => 'local and remote users have profiles',
|
||||
'fields' => array(
|
||||
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
|
||||
@ -74,6 +74,14 @@ class Profile extends Managed_DataObject
|
||||
'profile_nickname_idx' => array('nickname'),
|
||||
)
|
||||
);
|
||||
|
||||
// Add a fulltext index
|
||||
|
||||
if (common_config('search', 'type') == 'fulltext') {
|
||||
$def['fulltext indexes'] = array('nickname' => array('nickname', 'fullname', 'location', 'bio', 'homepage'));
|
||||
}
|
||||
|
||||
return $def;
|
||||
}
|
||||
|
||||
function multiGet($keyCol, $keyVals, $skipNulls=true)
|
||||
|
@ -630,6 +630,11 @@ class Schema
|
||||
$this->appendCreateIndex($statements, $tableName, $indexName, $def['indexes'][$indexName]);
|
||||
}
|
||||
|
||||
foreach ($fulltext['mod'] + $fulltext['add'] as $indexName) {
|
||||
$colDef = $def['fulltext indexes'][$indexName];
|
||||
$this->appendCreateFulltextIndex($statements, $tableName, $indexName, $colDef);
|
||||
}
|
||||
|
||||
return $statements;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user