3 use Illuminate\Database\Migrations\Migration;
4 use Illuminate\Database\Schema\Blueprint;
5 use Illuminate\Support\Facades\Schema;
7 return new class extends Migration
12 public function up(): void
14 Schema::table('books', function (Blueprint $table) {
15 $table->index('slug');
16 $table->index('created_by');
17 $table->index('updated_by');
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');
27 Schema::table('page_revisions', function (Blueprint $table) {
28 $table->index('page_id');
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');
37 Schema::table('activities', function (Blueprint $table) {
38 $table->index('book_id');
39 $table->index('user_id');
40 $table->index('entity_id');
42 Schema::table('views', function (Blueprint $table) {
43 $table->index('user_id');
44 $table->index('viewable_id');
49 * Reverse the migrations.
51 public function down(): void
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');
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');
66 Schema::table('page_revisions', function (Blueprint $table) {
67 $table->dropIndex('page_revisions_page_id_index');
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');
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');
81 Schema::table('views', function (Blueprint $table) {
82 $table->dropIndex('views_user_id_index');
83 $table->dropIndex('views_viewable_id_index');