Arquivo episodios
public function up()
{
Schema::create('episodios', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('numero');
$table->unsignedBigInteger('temporada_id');
$table->foreign('temporada_id')
->references('id')
->on('temporadas');
});
}
Arquivo temporadas
public function up()
{
Schema::create('temporadas', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('numero');
$table->unsignedBigInteger('serie_id');
$table->foreign('serie_id')
->reference('id')
->on('series');
});
}
Resultado
jose@corei57600k:~/Desenvolvimento/Laravel/controle-series$ php artisan migrate
Migrating: 2020_05_29_021500_create_temporadas_table
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 (SQL: alter table `temporadas` add constraint `temporadas_serie_id_foreign` foreign key (`serie_id`) references `series` ())
at /home/jose/Desenvolvimento/Laravel/controle-series/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1")
/home/jose/Desenvolvimento/Laravel/controle-series/vendor/laravel/framework/src/Illuminate/Database/Connection.php:452
2 PDO::prepare()
/home/jose/Desenvolvimento/Laravel/controle-series/vendor/laravel/framework/src/Illuminate/Database/Connection.php:452
Please use the argument -v to see more details.
O que pode estar ocorrendo?