laravel-oci8 icon indicating copy to clipboard operation
laravel-oci8 copied to clipboard

use increments when db:seed again insert mistakes because nextval

Open hsiaowei opened this issue 6 years ago • 1 comments

There are some problems with using laravel-oci8:

Code snippet of problem

When i set id increments,$table->increments('id'); Triggers will be set》》》:begin if :new.id is null then select sys_menu_id_seq.nextval into :new.id from dual; end if; end;《《《 but i need Some places need to specify ID when use db:seed(Because the menu ID needs to be related, I have to specify it.),so When I use it again sys_menu_id_seq.nextval will less than(current DB.id) There will be mistakes. error : ORA-00001: unique constraint (SYS_MENU_MENU_ID_PK) violated So I recommend that you set the last_number of the specified sequence:table.max(id)+1 into :new.id

  • Operating System
  • PHP 7.1
  • Laravel 5.5
  • Laravel-OCI8 v5.5.9

hsiaowei avatar Jan 02 '19 06:01 hsiaowei

So I recommend that you set the last_number of the specified sequence:table.max(id)+1 into :new.id

Thanks but no. I suggest you run a statement that changes the last number of the sequence after seeding.

// do seed
DB::statement('sql to set the last sequence number.')

yajra avatar Feb 20 '19 01:02 yajra

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

github-actions[bot] avatar Nov 07 '22 03:11 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Nov 15 '22 03:11 github-actions[bot]