osdd:seed
osdd:seed runs every seeder a layer registered with loadSeeders(), in priority order.
php artisan osdd:seed
Options
| Option | Description |
|---|---|
--layer | Only run the seeders of these layers. Full or package name, repeated or comma-separated. |
--fresh | Run migrate:fresh before seeding: drop every table and run every migration. |
--refresh | Run migrate:refresh before seeding: roll back and run every migration. |
--database | The database connection to migrate and seed. |
--force | Run 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:freshormigrate:refreshfails, 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.