Skip to content

Commit 6cb8db7

Browse files
authored
Add composite indexes (#1360)
1 parent 8f0ff08 commit 6cb8db7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
public function up(): void
10+
{
11+
Schema::table('likes', function (Blueprint $table) {
12+
$table->index(['likeable_id', 'likeable_type']);
13+
$table->index(['likeable_id', 'likeable_type', 'created_at']);
14+
});
15+
16+
Schema::table('taggables', function (Blueprint $table) {
17+
$table->dropIndex(['taggable_id']);
18+
19+
$table->index(['taggable_id', 'taggable_type']);
20+
});
21+
22+
Schema::table('replies', function (Blueprint $table) {
23+
$table->dropIndex(['replyable_id']);
24+
$table->dropIndex(['replyable_type']);
25+
26+
$table->index(['replyable_id', 'replyable_type']);
27+
});
28+
}
29+
};

0 commit comments

Comments
 (0)