Wednesday, March 29, 2017

Eloquent Foreign key constraint is incorrectly formed laravel

I am trying to add a foreign key to the 'users' table. These are the time stamps of the migration

eloquent_migrations

And this is the code:

Schema::create('tasks', function (Blueprint $table) {
        $table->increments('id');
        $table->string('types');
        $table->timestamps();
    });

Schema::create('users', function (Blueprint $table) {
        //...
        $table->integer('type')->length(10)->unsigned();;
        $table->foreign('type')->references('id')->on('types')->onDelete('cascade');
        $table->rememberToken();
        $table->timestamps();
    });

I really don't know what I do wrong.



via Ileana Profeanu

Advertisement