mardi 20 décembre 2016

Laravel Migrate creating duplicate foreign key names

Schema::create('a', function(Blueprint $table) { 
$table- > bigInteger('id'); $table -> primary('id'); 
});

Schema::create('b', function(Blueprint $table) { 
$table -> bigInteger('id');
$table -> bigInteger('a_id');
$table -> foreign('a_id') -> references('id') -> on('a');
});

 Schema::create('c', function(Blueprint $table) { 
$table -> bigInteger('id');
$table -> bigInteger('a_id');
$table -> foreign('a_id') -> references('id') -> on('a'); 
});

Running this with php artisan migrate on this gives me a

ORA-02264: name already used by an existing constraint.

It seems that migrate creates a constraint on b called A_ID_PK, then it tries to create a constrain on c called A_ID_PK and errors since there are 2 A_ID_PK constraints on the A.id. Am I correct, and if so is there a solution?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire