Skip to content

Commit 40b5c8d

Browse files
committed
Add indexes on tables
1 parent 195270d commit 40b5c8d

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Database\Migrations\Migration;
5+
6+
class AddIndexes extends Migration
7+
{
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::table('forum_threads', function (Blueprint $table) {
16+
$table->index('author_id');
17+
$table->index('most_recent_reply_id');
18+
$table->index('solution_reply_id');
19+
});
20+
21+
Schema::table('forum_replies', function (Blueprint $table) {
22+
$table->index('author_id');
23+
$table->index('thread_id');
24+
});
25+
26+
Schema::table('comments', function (Blueprint $table) {
27+
$table->index('author_id');
28+
});
29+
}
30+
31+
/**
32+
* Reverse the migrations.
33+
*
34+
* @return void
35+
*/
36+
public function down()
37+
{
38+
Schema::table('forum_threads', function (Blueprint $table) {
39+
$table->dropIndex('author_id');
40+
$table->dropIndex('most_recent_reply_id');
41+
$table->dropIndex('solution_reply_id');
42+
});
43+
44+
Schema::table('forum_replies', function (Blueprint $table) {
45+
$table->dropIndex('author_id');
46+
$table->dropIndex('thread_id');
47+
});
48+
49+
Schema::table('comments', function (Blueprint $table) {
50+
$table->dropIndex('author_id');
51+
});
52+
}
53+
}

0 commit comments

Comments
 (0)