BookStack/database/migrations/2015_12_05_145049_fulltext_weighting.php
Dan Brown eebfd8904e
Removed old fulltext indexes from migrations
Prevents forcing of MyISAM for some databases
Removed old code to add indexes and added checks for existing indexes before removal.
Should still allow upgrades, rollbacks to old bookstack versions may be funky but
should not be high use-case.
2018-09-23 00:30:48 +01:00

54 lines
1.6 KiB
PHP

<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class FulltextWeighting extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// This was removed for v0.24 since these indexes are removed anyway
// and will cause issues for db engines that don't support such indexes.
// $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)");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$sm = Schema::getConnection()->getDoctrineSchemaManager();
$pages = $sm->listTableDetails('pages');
$books = $sm->listTableDetails('books');
$chapters = $sm->listTableDetails('chapters');
if ($pages->hasIndex('name_search')) {
Schema::table('pages', function(Blueprint $table) {
$table->dropIndex('name_search');
});
}
if ($books->hasIndex('name_search')) {
Schema::table('books', function(Blueprint $table) {
$table->dropIndex('name_search');
});
}
if ($chapters->hasIndex('name_search')) {
Schema::table('chapters', function(Blueprint $table) {
$table->dropIndex('name_search');
});
}
}
}