]> BookStack Code Mirror - bookstack/blob - database/migrations/2015_11_26_221857_add_entity_indexes.php
09773b1f3b0174eb2d154df4da3226c399a2d5fc
[bookstack] / database / migrations / 2015_11_26_221857_add_entity_indexes.php
1 <?php
2
3 use Illuminate\Database\Migrations\Migration;
4 use Illuminate\Database\Schema\Blueprint;
5
6 class AddEntityIndexes extends Migration
7 {
8     /**
9      * Run the migrations.
10      *
11      * @return void
12      */
13     public function up()
14     {
15         Schema::table('books', function (Blueprint $table) {
16             $table->index('slug');
17             $table->index('created_by');
18             $table->index('updated_by');
19         });
20         Schema::table('pages', function (Blueprint $table) {
21             $table->index('slug');
22             $table->index('book_id');
23             $table->index('chapter_id');
24             $table->index('priority');
25             $table->index('created_by');
26             $table->index('updated_by');
27         });
28         Schema::table('page_revisions', function (Blueprint $table) {
29             $table->index('page_id');
30         });
31         Schema::table('chapters', function (Blueprint $table) {
32             $table->index('slug');
33             $table->index('book_id');
34             $table->index('priority');
35             $table->index('created_by');
36             $table->index('updated_by');
37         });
38         Schema::table('activities', function (Blueprint $table) {
39             $table->index('book_id');
40             $table->index('user_id');
41             $table->index('entity_id');
42         });
43         Schema::table('views', function (Blueprint $table) {
44             $table->index('user_id');
45             $table->index('viewable_id');
46         });
47     }
48
49     /**
50      * Reverse the migrations.
51      *
52      * @return void
53      */
54     public function down()
55     {
56         Schema::table('books', function (Blueprint $table) {
57             $table->dropIndex('books_slug_index');
58             $table->dropIndex('books_created_by_index');
59             $table->dropIndex('books_updated_by_index');
60         });
61         Schema::table('pages', function (Blueprint $table) {
62             $table->dropIndex('pages_slug_index');
63             $table->dropIndex('pages_book_id_index');
64             $table->dropIndex('pages_chapter_id_index');
65             $table->dropIndex('pages_priority_index');
66             $table->dropIndex('pages_created_by_index');
67             $table->dropIndex('pages_updated_by_index');
68         });
69         Schema::table('page_revisions', function (Blueprint $table) {
70             $table->dropIndex('page_revisions_page_id_index');
71         });
72         Schema::table('chapters', function (Blueprint $table) {
73             $table->dropIndex('chapters_slug_index');
74             $table->dropIndex('chapters_book_id_index');
75             $table->dropIndex('chapters_priority_index');
76             $table->dropIndex('chapters_created_by_index');
77             $table->dropIndex('chapters_updated_by_index');
78         });
79         Schema::table('activities', function (Blueprint $table) {
80             $table->dropIndex('activities_book_id_index');
81             $table->dropIndex('activities_user_id_index');
82             $table->dropIndex('activities_entity_id_index');
83         });
84         Schema::table('views', function (Blueprint $table) {
85             $table->dropIndex('views_user_id_index');
86             $table->dropIndex('views_viewable_id_index');
87         });
88     }
89 }