3 use Illuminate\Database\Migrations\Migration;
4 use Illuminate\Database\Schema\Blueprint;
5 use Illuminate\Support\Facades\DB;
6 use Illuminate\Support\Facades\Schema;
8 return new class 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.
27 public function down(): void
29 $sm = Schema::getConnection()->getDoctrineSchemaManager();
30 $prefix = DB::getTablePrefix();
31 $pages = $sm->introspectTable($prefix . 'pages');
32 $books = $sm->introspectTable($prefix . 'books');
33 $chapters = $sm->introspectTable($prefix . 'chapters');
35 if ($pages->hasIndex('search')) {
36 Schema::table('pages', function (Blueprint $table) {
37 $table->dropIndex('search');
41 if ($books->hasIndex('search')) {
42 Schema::table('books', function (Blueprint $table) {
43 $table->dropIndex('search');
47 if ($chapters->hasIndex('search')) {
48 Schema::table('chapters', function (Blueprint $table) {
49 $table->dropIndex('search');