| 
									
										
										
										
											2015-11-27 07:45:04 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use Illuminate\Database\Migrations\Migration; | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  | use Illuminate\Database\Schema\Blueprint; | 
					
						
							| 
									
										
										
										
											2015-11-27 07:45:04 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class AddEntityIndexes extends Migration | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Run the migrations. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return void | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function up() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         Schema::table('books', function (Blueprint $table) { | 
					
						
							|  |  |  |             $table->index('slug'); | 
					
						
							|  |  |  |             $table->index('created_by'); | 
					
						
							|  |  |  |             $table->index('updated_by'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |         Schema::table('pages', function (Blueprint $table) { | 
					
						
							|  |  |  |             $table->index('slug'); | 
					
						
							|  |  |  |             $table->index('book_id'); | 
					
						
							|  |  |  |             $table->index('chapter_id'); | 
					
						
							|  |  |  |             $table->index('priority'); | 
					
						
							|  |  |  |             $table->index('created_by'); | 
					
						
							|  |  |  |             $table->index('updated_by'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |         Schema::table('page_revisions', function (Blueprint $table) { | 
					
						
							|  |  |  |             $table->index('page_id'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |         Schema::table('chapters', function (Blueprint $table) { | 
					
						
							|  |  |  |             $table->index('slug'); | 
					
						
							|  |  |  |             $table->index('book_id'); | 
					
						
							|  |  |  |             $table->index('priority'); | 
					
						
							|  |  |  |             $table->index('created_by'); | 
					
						
							|  |  |  |             $table->index('updated_by'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |         Schema::table('activities', function (Blueprint $table) { | 
					
						
							|  |  |  |             $table->index('book_id'); | 
					
						
							|  |  |  |             $table->index('user_id'); | 
					
						
							|  |  |  |             $table->index('entity_id'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |         Schema::table('views', function (Blueprint $table) { | 
					
						
							|  |  |  |             $table->index('user_id'); | 
					
						
							|  |  |  |             $table->index('viewable_id'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Reverse the migrations. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return void | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function down() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         Schema::table('books', function (Blueprint $table) { | 
					
						
							| 
									
										
										
										
											2015-11-30 01:33:25 +08:00
										 |  |  |             $table->dropIndex('books_slug_index'); | 
					
						
							|  |  |  |             $table->dropIndex('books_created_by_index'); | 
					
						
							|  |  |  |             $table->dropIndex('books_updated_by_index'); | 
					
						
							| 
									
										
										
										
											2015-11-27 07:45:04 +08:00
										 |  |  |         }); | 
					
						
							|  |  |  |         Schema::table('pages', function (Blueprint $table) { | 
					
						
							| 
									
										
										
										
											2015-11-30 01:33:25 +08:00
										 |  |  |             $table->dropIndex('pages_slug_index'); | 
					
						
							|  |  |  |             $table->dropIndex('pages_book_id_index'); | 
					
						
							|  |  |  |             $table->dropIndex('pages_chapter_id_index'); | 
					
						
							|  |  |  |             $table->dropIndex('pages_priority_index'); | 
					
						
							|  |  |  |             $table->dropIndex('pages_created_by_index'); | 
					
						
							|  |  |  |             $table->dropIndex('pages_updated_by_index'); | 
					
						
							| 
									
										
										
										
											2015-11-27 07:45:04 +08:00
										 |  |  |         }); | 
					
						
							|  |  |  |         Schema::table('page_revisions', function (Blueprint $table) { | 
					
						
							| 
									
										
										
										
											2015-11-30 01:33:25 +08:00
										 |  |  |             $table->dropIndex('page_revisions_page_id_index'); | 
					
						
							| 
									
										
										
										
											2015-11-27 07:45:04 +08:00
										 |  |  |         }); | 
					
						
							|  |  |  |         Schema::table('chapters', function (Blueprint $table) { | 
					
						
							| 
									
										
										
										
											2015-11-30 01:33:25 +08:00
										 |  |  |             $table->dropIndex('chapters_slug_index'); | 
					
						
							|  |  |  |             $table->dropIndex('chapters_book_id_index'); | 
					
						
							|  |  |  |             $table->dropIndex('chapters_priority_index'); | 
					
						
							|  |  |  |             $table->dropIndex('chapters_created_by_index'); | 
					
						
							|  |  |  |             $table->dropIndex('chapters_updated_by_index'); | 
					
						
							| 
									
										
										
										
											2015-11-27 07:45:04 +08:00
										 |  |  |         }); | 
					
						
							|  |  |  |         Schema::table('activities', function (Blueprint $table) { | 
					
						
							| 
									
										
										
										
											2015-11-30 01:33:25 +08:00
										 |  |  |             $table->dropIndex('activities_book_id_index'); | 
					
						
							|  |  |  |             $table->dropIndex('activities_user_id_index'); | 
					
						
							|  |  |  |             $table->dropIndex('activities_entity_id_index'); | 
					
						
							| 
									
										
										
										
											2015-11-27 07:45:04 +08:00
										 |  |  |         }); | 
					
						
							|  |  |  |         Schema::table('views', function (Blueprint $table) { | 
					
						
							| 
									
										
										
										
											2015-11-30 01:33:25 +08:00
										 |  |  |             $table->dropIndex('views_user_id_index'); | 
					
						
							|  |  |  |             $table->dropIndex('views_viewable_id_index'); | 
					
						
							| 
									
										
										
										
											2015-11-27 07:45:04 +08:00
										 |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |