Improved DB prefix support and removed old search method

This commit is contained in:
Dan Brown
2017-04-09 14:44:56 +01:00
parent 01cb22af37
commit 37813a223a
4 changed files with 29 additions and 70 deletions

View File

@ -12,9 +12,10 @@ class AddSearchIndexes extends Migration
*/
public function up()
{
DB::statement('ALTER TABLE pages ADD FULLTEXT search(name, text)');
DB::statement('ALTER TABLE books ADD FULLTEXT search(name, description)');
DB::statement('ALTER TABLE chapters ADD FULLTEXT search(name, description)');
$prefix = DB::getTablePrefix();
DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT search(name, text)");
DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)");
DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)");
}
/**

View File

@ -12,9 +12,10 @@ class FulltextWeighting extends Migration
*/
public function up()
{
DB::statement('ALTER TABLE pages ADD FULLTEXT name_search(name)');
DB::statement('ALTER TABLE books ADD FULLTEXT name_search(name)');
DB::statement('ALTER TABLE chapters ADD FULLTEXT name_search(name)');
$prefix = DB::getTablePrefix();
DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)");
DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)");
DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)");
}
/**

View File

@ -26,7 +26,19 @@ class CreateSearchIndexTable extends Migration
$table->index('score');
});
// TODO - Drop old fulltext indexes
// Drop search indexes
Schema::table('pages', function(Blueprint $table) {
$table->dropIndex('search');
$table->dropIndex('name_search');
});
Schema::table('books', function(Blueprint $table) {
$table->dropIndex('search');
$table->dropIndex('name_search');
});
Schema::table('chapters', function(Blueprint $table) {
$table->dropIndex('search');
$table->dropIndex('name_search');
});
app(\BookStack\Services\SearchService::class)->indexAllEntities();
}
@ -38,6 +50,14 @@ class CreateSearchIndexTable extends Migration
*/
public function down()
{
$prefix = DB::getTablePrefix();
DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT search(name, text)");
DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)");
DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)");
DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)");
DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)");
DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)");
Schema::dropIfExists('search_terms');
}
}