Skip to content

Latest commit

 

History

History
71 lines (49 loc) · 1.44 KB

README.md

File metadata and controls

71 lines (49 loc) · 1.44 KB

Run Database seeders with history like migrations

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.

Installation

Install via composer

composer require codepluswander/laravel-database-seed-version

Run the migrations to create the seeders table

php artisan migrate

Usage

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]);
        });
    }
}

Testing

composer test

Changelog

Refer to CHANGELOG for recent changes.

License

The MIT License (MIT) License File.