1

I have run this seeder:

private function seedUsers()
{
    $users = [
        [
            'name'       => '**',
            'email'      => 'admin@**.com',
            'gender'     => '**',
            'privacy'    => '**',
            'password'    => '**',
            'country_id' => *,
            'city_id'    => *,
            'role_id'    => *,
        ],
    ];
    foreach ($users as $user) {
        factory(App\Services\Users\User::class)->create($user);
    }
    factory(App\Services\Users\User::class, 10)->create();// This line was included by mistake.
}

Is there away to to undo this seeder and re-run it after I have removed the line that adds 10 test users?

I'm using Laravel5.5

Bear in mind, I have these users' email addresses and that this is not a testing DB, so I need to only remove these 10 test users.

Seio. E.
  • 297
  • 2
  • 7
  • 18
  • 3
    use this command : php artisan migrate:refresh --seed – abrar Apr 19 '18 at 07:25
  • No, this is on prod. but thnx. – Seio. E. Apr 19 '18 at 07:26
  • unfortunately i think there's nothing native on laravel about that. You'll have to install a package like [undo-seeder](https://github.com/killmenot/undo-seeder-laravel) but you have to install it before to keep track or do a "manual rollback" by removing everything your seeder generated. – bLuke Apr 19 '18 at 07:47

1 Answers1

0

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.
Yudiz Solutions
  • 4,216
  • 2
  • 7
  • 21