I'm creating a ManyToMany relationship with the Laravel framework v.5.7. So I created three migrations.
Modules Table
Schema::create('modules', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->integer('price');
});
Plans Table
Schema::create('plans', function (Blueprint $table) {
$table->increments('id');
$table->string('stripe_id')->unique();
$table->integer('price');
$table->integer('max_users');
$table->timestamps();
});
Relation Table
Schema::create('plan_modules', function (Blueprint $table) {
$table->increments('id');
$table->integer('plan_id')->unsigend()->onDelete('cascade');
$table->integer('module_id')->unsigend()->onDelete('cascade');
// Keys
$table->foreign('plan_id')->references('id')->on('plans');
$table->foreign('module_id')->references('id')->on('modules');
});
Whe I run the migration I get General error: 1215 Cannot add foreign key constraint
.
Dose anyone has a idea what is wrong with the migrations. The default engine for mysql is set to InnoDB
.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire