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