jeudi 16 juin 2016

Seeding Table with auto increment field as zero

I created a seeder for a table, and the first record I am trying to insert has ID=0. The ID is an auto increment field, and when it gets inserted, I check its ID and it is 1 instead of 0, so the seeder breaks in the next line, when I try to create a record with ID 1.

How can I insert several records, with the first having an ID of 0?

This is the code I have:

DB::table('payment_status')->delete();
DB::table('payment_status')->insert(array('id' => '0', 'name' => 'Initial'));
DB::table('payment_status')->insert(array('id' => '1', 'name' => 'Payment successful, Waiting for Processing'));



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire