Engine23

Laravel Workbench Migrations & Seeds

Having some fun learning the Laravel framework and was trying to figure out how to do migrations and seeds for workbench packages. In general these are the commands, but read the rest for the particulars.

php artisan migrate --bench="Upshot/Poll"
php artisan migrate:rollback
php artisan db:seed --class="UpshotPollDatabaseSeeder"

 Migrations are covered fairly well at http://laravel.com/docs/packages, with the only addition being is to roll back you call migrate:rollback without any switches.

Seed are the hard part.  First you'll create a database folder with the subfolder seeds in the workbench package's src folder.  You'll place your packages base seeder there.

class BaseDatabaseSeeder extends Seeder {
public function run()
{
//$this->call('SubSeeder');
$this->command->info('Tables seeded!');
}
}

Then you'll register the seeders in classmap so they can be found:

"classmap": [
"src/migrations",
"src/database/seeds"
],

Rebuild everything with:

php artisan dump-autoload

Finally run the packages seeder with:

php artisan db:seed --class="BaseDatabaseSeeder"

From there everything should be standard.

Share: