I have multiple migrations but the two which I think are relevant to this question are the 'job' and 'session' migrations.
Job Migration
Schema::create('job', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->timestamps();
});
Sessions Migration:
Schema::create('session', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('group_id');
$table->unsignedBigInteger('job_id');
$table->boolean('verified')->default(0);
$table->date('date');
$table->time('start_time');
$table->time('end_time');
$table->string('session_type');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('group_id')->references('id')->on('group');
$table->foreign('job_id')->references('id')->on('job');
});
Now the error I get when I make migration is:
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table
session
add constraintsession_job_id_foreign
foreign key (job_id
) referencesjob
(id
))
Database: MySQL
I don't understand what the issue is here. This approach has always worked for me, even in this current Laravel project.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire