Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel seed rollback after seeding database

I have seeded my DB using php artisan db::seed. Is there a way to rollback what I have seeded into my DB?

I cannot seem to find any command like php artisan db::seed rollback.

like image 297
Aaron Avatar asked Jun 23 '17 20:06

Aaron


People also ask

How do I roll back a DB seed in Laravel?

use Undo Seeder for Laravel. When you install UndoSeeder, the following artisan commands are made available: db:seed-undo Undo seeds in the seeds directory. db:seed-refresh Undo seeds run seeds again.

How do I undo a DB seed?

There are two commands that can revert seeds: db:seed:undo:all reverts all seeds, while db:seed:undo --seed [filename] will revert the most recent seed. However, by default, a list of seeders is not stored in a database table like migrations.

How do I rollback in Laravel?

How to rollback a specific migration in laravel ? Step 1 : Open database and check migrations table. Step 2 : Change batch number to last number. Step 3 : Run artisan rollback command.

How does Laravel seeding work?

Laravel includes the ability to seed your database with data using seed classes. All seed classes are stored in the database/seeders directory. By default, a DatabaseSeeder class is defined for you. From this class, you may use the call method to run other seed classes, allowing you to control the seeding order.


1 Answers

use Undo Seeder for Laravel.

When you install UndoSeeder, the following artisan commands are made available:

db:seed-undo    Undo seeds in the seeds directory.
db:seed-refresh Undo seeds run seeds again.

more Undo-Seeder

like image 127
Leo Avatar answered Sep 20 '22 14:09

Leo