laravel-oci8
laravel-oci8 copied to clipboard
ORA-02264: name already used by an existing constraint
Summary of problem or feature request
During the initial migration of a table with two constraints, the query creates a duplicate constraint name causing an error. This same migration will run with MySQL without error.
Code snippet of problem
Schema::create('permission_role', function (Blueprint $table) {
$table->integer('permission_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->foreign('permission_id')
->references('id')
->on('permissions')
->onDelete('cascade');
$table->foreign('role_id')
->references('id')
->on('roles')
->onDelete('cascade');
$table->primary(['permission_id', 'role_id']);
});
[Yajra\Pdo\Oci8\Exceptions\Oci8Exception]
Error Code : 2264
Error Message : ORA-02264: name already used by an existing constraint
Position : 110
Statement : create table permission_role ( permission_id number(10,0) n
ot null, role_id number(10,0) not null, constraint permission_role_permissi
on_id_ foreign key ( permission_id ) references permissions ( id ) on delet
e cascade, constraint permission_role_role_id_fk foreign key ( role_id ) re
ferences roles ( id ) on delete cascade, constraint permission_role_permiss
ion_id_ primary key ( permission_id, role_id ) )
Bindings : []
System details
- OS: Docker Debian 8
- PHP 7.1.11
- Laravel Version: ^5.5.*
- Laravel-OCI8 Version: 5.5
Oracle has a 30 char limit on object names. Given this, you need to manually set the constraint name or upgrade to Laravel 5.6 version if possible. This was addressed on #391.
$table->foreign('permission_id', 'perm_role_fk')...
This issue is stale because it has been open for 30 days with no activity.