| 
									
										
										
										
											2015-09-01 03:11:44 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use Illuminate\Database\Migrations\Migration; | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  | use Illuminate\Database\Schema\Blueprint; | 
					
						
							| 
									
										
										
										
											2024-03-19 18:30:26 +08:00
										 |  |  | use Illuminate\Support\Facades\DB; | 
					
						
							| 
									
										
										
										
											2024-03-17 23:29:09 +08:00
										 |  |  | use Illuminate\Support\Facades\Schema; | 
					
						
							| 
									
										
										
										
											2015-09-01 03:11:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-07 00:58:29 +08:00
										 |  |  | return new class extends Migration | 
					
						
							| 
									
										
										
										
											2015-09-01 03:11:44 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Run the migrations. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     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. | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2024-03-17 23:29:09 +08:00
										 |  |  |     public function down(): void | 
					
						
							| 
									
										
										
										
											2015-09-01 03:11:44 +08:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-01-11 21:22:49 +08:00
										 |  |  |         if (Schema::hasIndex('pages', 'search')) { | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  |             Schema::table('pages', function (Blueprint $table) { | 
					
						
							| 
									
										
										
										
											2018-09-23 07:30:48 +08:00
										 |  |  |                 $table->dropIndex('search'); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-11 21:22:49 +08:00
										 |  |  |         if (Schema::hasIndex('books', 'search')) { | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  |             Schema::table('books', function (Blueprint $table) { | 
					
						
							| 
									
										
										
										
											2018-09-23 07:30:48 +08:00
										 |  |  |                 $table->dropIndex('search'); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-11 21:22:49 +08:00
										 |  |  |         if (Schema::hasIndex('chapters', 'search')) { | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  |             Schema::table('chapters', function (Blueprint $table) { | 
					
						
							| 
									
										
										
										
											2018-09-23 07:30:48 +08:00
										 |  |  |                 $table->dropIndex('search'); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-09-01 03:11:44 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-02-07 00:58:29 +08:00
										 |  |  | }; |