3 use Illuminate\Database\Migrations\Migration;
4 use Illuminate\Database\Schema\Blueprint;
6 class AddSearchIndexes extends Migration
15 // This was removed for v0.24 since these indexes are removed anyway
16 // and will cause issues for db engines that don't support such indexes.
18 // $prefix = DB::getTablePrefix();
19 // DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT search(name, text)");
20 // DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)");
21 // DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)");
25 * Reverse the migrations.
29 public function down()
31 $sm = Schema::getConnection()->getDoctrineSchemaManager();
32 $pages = $sm->listTableDetails('pages');
33 $books = $sm->listTableDetails('books');
34 $chapters = $sm->listTableDetails('chapters');
36 if ($pages->hasIndex('search')) {
37 Schema::table('pages', function (Blueprint $table) {
38 $table->dropIndex('search');
42 if ($books->hasIndex('search')) {
43 Schema::table('books', function (Blueprint $table) {
44 $table->dropIndex('search');
48 if ($chapters->hasIndex('search')) {
49 Schema::table('chapters', function (Blueprint $table) {
50 $table->dropIndex('search');