2015_11_26_221857_add_entity_indexes.php
3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
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) {
$table->dropIndex('books_slug_index');
$table->dropIndex('books_created_by_index');
$table->dropIndex('books_updated_by_index');
});
Schema::table('pages', function (Blueprint $table) {
$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');
});
Schema::table('page_revisions', function (Blueprint $table) {
$table->dropIndex('page_revisions_page_id_index');
});
Schema::table('chapters', function (Blueprint $table) {
$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');
});
Schema::table('activities', function (Blueprint $table) {
$table->dropIndex('activities_book_id_index');
$table->dropIndex('activities_user_id_index');
$table->dropIndex('activities_entity_id_index');
});
Schema::table('views', function (Blueprint $table) {
$table->dropIndex('views_user_id_index');
$table->dropIndex('views_viewable_id_index');
});
}
}