Commands

osdd:seed

Run the seeders registered by every layer, or by some layers.

osdd:seed runs every seeder a layer registered with loadSeeders(), in priority order.

php artisan osdd:seed

Options

OptionDescription
--layerOnly run the seeders of these layers. Full or package name, repeated or comma-separated.
--freshRun migrate:fresh before seeding: drop every table and run every migration.
--refreshRun migrate:refresh before seeding: roll back and run every migration.
--databaseThe database connection to migrate and seed.
--forceRun in production without asking.
php artisan osdd:seed --fresh
php artisan osdd:seed --fresh --force --database=reporting
php artisan osdd:seed --layer=functional/orders --layer=billing

--fresh and --refresh cannot be combined. --database and --force are forwarded to db:seed, and to migrate:fresh or migrate:refresh.

Exit codes

osdd:seed returns the exit code of the step that failed:

  • when migrate:fresh or migrate:refresh fails, nothing is seeded and the command returns its code;
  • otherwise it returns the exit code of db:seed.

A seeder that throws stops the run: the next seeders do not run. A class registered with loadSeeders() that does not exist fails the run before any seeder runs, with Lomkit\Osdd\Seeders\SeederNotFoundException, so a typo in a provider fails osdd:seed and your CI.

In production, db:seed asks for confirmation once. A cancelled run seeds nothing and exits with 1. Without a terminal, db:seed cancels itself: pass --force.

Seeding some layers

php artisan osdd:seed --layer=functional/orders --layer=billing
php artisan osdd:seed --layer=orders,billing

Only the seeders whose class belongs to those layers run, still in priority order. A seeder belongs to the layer with the longest matching psr-4 prefix. Names resolve like the generators' --layer: an unknown or ambiguous name fails with exit code 1 before anything runs, --fresh included. A selected layer without seeders prints No OSDD seeders registered for functional/orders..

Registering and ordering seeders

Layers register their seeders with loadSeeders() in their provider, with an optional priority. See Seeders.