8

I've been using Laravel's migrations with the path parameter like so:

Artisan::call('migrate', array('--path' => 'path/to/my/Migrations'));

Is there anyway I can run the seed command in the same way? I have a number of seed files I want to use but I don't want to run them all at the same time.

Any advice appreciated.

Thanks

Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
Dan
  • 6,265
  • 8
  • 40
  • 56

4 Answers4

20

Instead of --path you can set --class with namespace to Seeder class.

Artisan::call('db:seed', [
    '--class' => 'Namespace\Seeds\DatabaseSeeder'
]);

This works on Laravel 5.1

danronmoon
  • 3,814
  • 5
  • 34
  • 56
gellezzz
  • 1,165
  • 2
  • 12
  • 21
2

To refresh the migrations and seed the database, this worked for me:

// Roll back all migrations and migrate them again
Artisan::call('migrate:refresh');
// Fill tables with seeds
Artisan::call('db:seed');

I had lots of seeds and the server was slow. In this case it helps to extend the maximum execution time.

// Extend maximum execution time to 3 minutes
set_time_limit(180);
Artisan::call('migrate:refresh');
Artisan::call('db:seed');
// Back to the default
set_time_limit(30);
matthiasgiger
  • 1,086
  • 9
  • 17
1

Seeding only

Artisan::call('db:seed');

Re-run all migration under specified path & run seeds as well

Artisan::call('migrate:refresh', array('--path' => 'path/to/my/Migrations', '--seed'));
Andreyco
  • 22,476
  • 5
  • 61
  • 65
  • 1
    Hi, when using the second command, I get the following error: The "--path" option does not exist. – Dan Jul 17 '13 at 14:04
0

Use syntax below and take advantage of type checking

Artisan::call('db:seed', [
    '--class' => UserSeeder::class
]);
Dionysios Arvanitis
  • 1,133
  • 9
  • 11