]> BookStack Code Mirror - bookstack/blob - database/migrations/2015_12_05_145049_fulltext_weighting.php
Merge branch 'Abijeet-master'
[bookstack] / database / migrations / 2015_12_05_145049_fulltext_weighting.php
1 <?php
2
3 use Illuminate\Database\Schema\Blueprint;
4 use Illuminate\Database\Migrations\Migration;
5
6 class FulltextWeighting extends Migration
7 {
8     /**
9      * Run the migrations.
10      *
11      * @return void
12      */
13     public function up()
14     {
15         $prefix = DB::getTablePrefix();
16         DB::statement("ALTER TABLE {$prefix}pages ADD FULLTEXT name_search(name)");
17         DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT name_search(name)");
18         DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT name_search(name)");
19     }
20
21     /**
22      * Reverse the migrations.
23      *
24      * @return void
25      */
26     public function down()
27     {
28         Schema::table('pages', function(Blueprint $table) {
29             $table->dropIndex('name_search');
30         });
31         Schema::table('books', function(Blueprint $table) {
32             $table->dropIndex('name_search');
33         });
34         Schema::table('chapters', function(Blueprint $table) {
35             $table->dropIndex('name_search');
36         });
37     }
38 }