Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORA-02264: name already used by an existing constraint #428

Closed
mcred opened this issue Apr 17, 2018 · 2 comments
Closed

ORA-02264: name already used by an existing constraint #428

mcred opened this issue Apr 17, 2018 · 2 comments

Comments

@mcred
Copy link

mcred commented Apr 17, 2018

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
@yajra
Copy link
Owner

yajra commented Apr 27, 2018

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')...

@yajra yajra added the question label Apr 27, 2018
@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Nov 16, 2022
@mcred mcred closed this as completed Nov 16, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants