2015-12-05 10:11:48 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
2021-06-26 11:23:15 -04:00
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
2015-12-05 10:11:48 -05:00
|
|
|
|
|
|
|
class FulltextWeighting extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
2018-09-22 19:30:48 -04:00
|
|
|
// 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)");
|
2015-12-05 10:11:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
2018-09-22 19:30:48 -04:00
|
|
|
$sm = Schema::getConnection()->getDoctrineSchemaManager();
|
|
|
|
$pages = $sm->listTableDetails('pages');
|
|
|
|
$books = $sm->listTableDetails('books');
|
|
|
|
$chapters = $sm->listTableDetails('chapters');
|
|
|
|
|
|
|
|
if ($pages->hasIndex('name_search')) {
|
2021-06-26 11:23:15 -04:00
|
|
|
Schema::table('pages', function (Blueprint $table) {
|
2018-09-22 19:30:48 -04:00
|
|
|
$table->dropIndex('name_search');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($books->hasIndex('name_search')) {
|
2021-06-26 11:23:15 -04:00
|
|
|
Schema::table('books', function (Blueprint $table) {
|
2018-09-22 19:30:48 -04:00
|
|
|
$table->dropIndex('name_search');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($chapters->hasIndex('name_search')) {
|
2021-06-26 11:23:15 -04:00
|
|
|
Schema::table('chapters', function (Blueprint $table) {
|
2018-09-22 19:30:48 -04:00
|
|
|
$table->dropIndex('name_search');
|
|
|
|
});
|
|
|
|
}
|
2015-12-05 10:11:48 -05:00
|
|
|
}
|
|
|
|
}
|