Master table POll
public function up()
{
Schema::create('poll', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('poll_question', 255);
$table->boolean('status',1)->default(0)->index();
$table->unsignedInteger('order');
});
}
Detail table
public function up()
{
Schema::create('poll_option', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('poll_id');
$table->string('poll_option', 255);
$table->unsignedInteger('vote_poll_option');
$table->unsignedInteger('order');
$table->boolean('status',1)->default(0)->index();
$table->foreign('poll_id')->references('id')->on('poll')->onUpdate('cascade')->onDelete('cascade');
});
}
When I run php artisan with foreign key
SQLSTATE[HY000]: General error: 1005 Can't create table
mydb
.#sql-6f4_433
(errno: 150 "Foreign key constraint is incorrectly formed")
Note: I m using laravel 5.2 and mysql type already Innodb What is main causes to incorrectly formed