dimanche 28 mai 2017

laravel 5 - How can i add ->index() to existing foreign key

I have the table "poptins":

    Schema::create('poptins', function (Blueprint $table) {
        $table->string('id')->primary()->index();
        $table->string('ab_test_parent_id')->nullable();
        $table->string('cloned_parent_id')->nullable();
        $table->timestamps();
    });

And the table "conversions":

    Schema::create('conversions', function (Blueprint $table) {
        $table->string('id')->primary()->index();
        $table->integer('users')->default(null);
        $table->string('name',256)->default(null);
        $table->string('poptin_id');
        $table->foreign('poptin_id')->references('id')->on('poptins')->onDelete('cascade')->onUpdate('cascade');
        $table->timestamps();
    });

I have set a foreign key (poptin_id) in the "conversions" table. Now does it's mean that the foreign key (poptin_id) is also a index? if not... what i need to do in order to make it a index?

Thank?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2rtWnbP
via IFTTT

Aucun commentaire:

Enregistrer un commentaire