This package allows you to run db:seed
and it will keep track which seeders were already ran and not run them again just like migrations.
Install via composer
composer require codepluswander/laravel-database-seed-version
Run the migrations to create the seeders
table
php artisan migrate
You can set seeder files in the config file
php artisan vendor:publish --provider="Codepluswander\LaravelDatabaseSeedVersion\DatabaseSeedVersionServiceProvider"
<?php
return [
'seeders' => [
\MyNameSpace\MySeeder::class
],
];
You can also set seeders in your AppServiceProvider
or any ServiceProvider register
function. Just call the addSeeder
function for the DatabaseSeederVersion
class after resolving it.
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Codepluswander\LaravelDatabaseSeedVersion\DatabaseSeederVersion;
use Database\Seeders\TestSeeder;
class AppServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->afterResolving(DatabaseSeederVersion::class, function ($service) {
$service->addSeeder([TestSeeder::class]);
});
}
}
composer test
Refer to CHANGELOG for recent changes.
The MIT License (MIT) License File.