]> BookStack Code Mirror - bookstack/blob - database/migrations/2015_08_31_175240_add_search_indexes.php
Lexical: Source code input changes
[bookstack] / database / migrations / 2015_08_31_175240_add_search_indexes.php
1 <?php
2
3 use Illuminate\Database\Migrations\Migration;
4 use Illuminate\Database\Schema\Blueprint;
5 use Illuminate\Support\Facades\DB;
6 use Illuminate\Support\Facades\Schema;
7
8 return new class extends Migration
9 {
10     /**
11      * Run the migrations.
12      */
13     public function up()
14     {
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.
17
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)");
22     }
23
24     /**
25      * Reverse the migrations.
26      */
27     public function down(): void
28     {
29         if (Schema::hasIndex('pages', 'search')) {
30             Schema::table('pages', function (Blueprint $table) {
31                 $table->dropIndex('search');
32             });
33         }
34
35         if (Schema::hasIndex('books', 'search')) {
36             Schema::table('books', function (Blueprint $table) {
37                 $table->dropIndex('search');
38             });
39         }
40
41         if (Schema::hasIndex('chapters', 'search')) {
42             Schema::table('chapters', function (Blueprint $table) {
43                 $table->dropIndex('search');
44             });
45         }
46     }
47 };