Answers for "add index in Laravel migration"

PHP
0

laravel migration index

$table->index(['account_id', 'created_at']);
Posted by: Guest on May-08-2020
0

add index in Laravel migration

<?php

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

class Products extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->id();
            $table->string('product_name')->index('product_name');
            $table->string('product_sku')->index('product_sku');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('products');
    }
}
Posted by: Guest on June-15-2021

Code answers related to "add index in Laravel migration"

Browse Popular Code Answers by Language