Skip to content

Drop Index in Migration Can't Find Index with Name #1036

@Oyelaking

Description

@Oyelaking

I get this output when running the migration rollback command. But the up method works fine, and creates the index as expected. It's rolling back(dropping the index that's the issue).

screen shot 2016-11-17 at 2 28 23 pm

This is the migration file content:

<?php

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

class CreateProductFacetsIndex extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::connection('productsdb')->table('products', function (Blueprint $collection) {
            $collection->index(
                [
                    "facets.name" => 1,
                    "facets.value" => 1,
                ],
                'facets_index',
                null,
                ['name' => 'facets_index']
            );
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::connection('productsdb')->table('products', function (Blueprint $collection) {
            $collection->dropIndex(['facets_index']);
        });
    }
}

I think this is a bug. Looking at the code, I see that '_1' is always appended to the index name when the dropIndex method is called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions