I have run a db:seed and in Laravel 5.4. Now I found that it was not to be run . So is there anyway in Laravel that we can undo the last db:seed and insert the table with previous data. Thanks in advance
Asked
Active
Viewed 5,425 times
2
-
Does this answer your question? [laravel seed rollback after seeding database](https://stackoverflow.com/questions/44729769/laravel-seed-rollback-after-seeding-database) – Alex Aug 27 '21 at 14:10
2 Answers
0
The only way to undo your seed(s) is by deleting them manually. With this sql command that should go pretty fast. As long as no data has been added after the seed you don't want to lose.
DELETE FROM {$table} ORDER BY created_at DESC LIMIT {$number_data_seeds}

Dimitri Mostrey
- 2,302
- 1
- 12
- 11
-1
Database: Seeding is not migration, you can not rollback the last seed.
You can rollback all migrations and re-run all of your migrations and run seed, but you need to understand that when rolling back migrations, you lose all the data.
php artisan migrate: refresh --seed
Alternatively, you can look in the database/seeds
folder and understand what changes you need to rollback and manually make changes to the database.
Please see the documentation https://laravel.com/docs/5.4/seeding can you find that useful.

Zualex
- 54
- 1
- 2
- 7