Support the ongoing development of Laravel.io →
Database Architecture
Last updated 1 year ago.
0

You can use

php artisan migrate:refresh --seed

It combines

php artisan migrate:reset
php artisan migrate
php artisan db:seed

Make sure that your down functions in your migrations is correct since it resets the database.

This will remove all the data in all your tables so don't use this if the data isn't only created from your seeds.

Last updated 1 year ago.
0

I'm just starting a new web app and have encountered the same issue.

Would it be best practice to not use auto incrementing ID's on tables that contain base data for an application? As in chrisgeary92's issue above: if the roles/permissions table didn't use incrementing ID's then you could just re-seed that table with new data and your ID's would remain the same.

Last updated 1 year ago.
0

You could still use auto-increments on the table even if you specify the ID explicitly when you insert. For example:

DB::table('foo')->insert(
    array('id' => 1, 'bar' => 'baz'),
    array('id' => 3, 'bar' => $whateverFillerWordComesAfterBaz)
);

Now if you insert another row without specifying an ID, the autoincrement should set it to 4.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.