Skip to content

Commit

Permalink
Optimize target type + ID index for more realistic use cases (#8923)
Browse files Browse the repository at this point in the history
  • Loading branch information
iansltx authored Jan 26, 2021
1 parent a48d09f commit 1d7d31b
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class SwapTargetTypeIndexOrder extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('action_logs', function (Blueprint $table) {
$table->dropIndex(['target_id', 'target_type']);
});

Schema::table('action_logs', function (Blueprint $table) {
$table->index(['target_type', 'target_id']);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('action_logs', function (Blueprint $table) {
$table->dropIndex(['target_type', 'target_id']);
});

Schema::table('action_logs', function (Blueprint $table) {
$table->index(['target_id', 'target_type']);
});
}
}

0 comments on commit 1d7d31b

Please sign in to comment.