We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 48625da0 authored by Evan Prodromou's avatar Evan Prodromou

Automatically add or drop fulltext indexes

parent 5b0192a8
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment