| 
									
										
										
										
											2015-09-01 03:11:44 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use Illuminate\Database\Schema\Blueprint; | 
					
						
							|  |  |  | use Illuminate\Database\Migrations\Migration; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AddSearchIndexes extends Migration | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Run the migrations. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return void | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function up() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-09-23 07:30:48 +08: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 search(name, text)");
 | 
					
						
							|  |  |  | //        DB::statement("ALTER TABLE {$prefix}books ADD FULLTEXT search(name, description)");
 | 
					
						
							|  |  |  | //        DB::statement("ALTER TABLE {$prefix}chapters ADD FULLTEXT search(name, description)");
 | 
					
						
							| 
									
										
										
										
											2015-09-01 03:11:44 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Reverse the migrations. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return void | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function down() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-09-23 07:30:48 +08:00
										 |  |  |         $sm = Schema::getConnection()->getDoctrineSchemaManager(); | 
					
						
							|  |  |  |         $pages = $sm->listTableDetails('pages'); | 
					
						
							|  |  |  |         $books = $sm->listTableDetails('books'); | 
					
						
							|  |  |  |         $chapters = $sm->listTableDetails('chapters'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ($pages->hasIndex('search')) { | 
					
						
							|  |  |  |             Schema::table('pages', function(Blueprint $table) { | 
					
						
							|  |  |  |                 $table->dropIndex('search'); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ($books->hasIndex('search')) { | 
					
						
							|  |  |  |             Schema::table('books', function(Blueprint $table) { | 
					
						
							|  |  |  |                 $table->dropIndex('search'); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ($chapters->hasIndex('search')) { | 
					
						
							|  |  |  |             Schema::table('chapters', function(Blueprint $table) { | 
					
						
							|  |  |  |                 $table->dropIndex('search'); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-01 03:11:44 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | } |