tabela temporadas no migrate
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTemporadasTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create("temporadas", function (Blueprint $table) {
$table->increments("id");
$table->integer("numero");
$table->integer('serie_id')->unsigned();
$table
->foreign("serie_id")
->references("id")
->on("series");
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('temporadas');
}
}
TABELA EPISODIOS do migrate
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateEpisodiosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('episodios', function (Blueprint $table) {
$table->increments("id");
$table->integer("numero");
$table->integer('temporada_id')->unsigned();
$table
->foreign("temporada_id")
->references("id")
->on("temporadas");
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('episodios');
}
}
Após o migrate não encontra ou não consegue abrir a referencia temporadas apresentando este erro
SQLSTATE[HY000]: General error: 1824 Failed to open the referenced table 'temporadas' (SQL: alter table `episodios` add constraint `episodios_temporada_id_foreign` foreign key (`temporada_id`) references `temporadas` (`id`))
`