Skip to content

seed

Execute seeder files to populate the database with development or test data.

Synopsis

bash
npx @orphnet/d1-eloquent seed --db <DB_NAME> [--local | --remote] [--seeder <Name>]

Options

FlagDescription
--db <DB_NAME>Required. The D1 binding name defined in wrangler.toml.
--localRun against the local D1 database. Default when neither flag is provided.
--remoteRun against the Cloudflare-hosted D1 database.
--seeder <Name>Run a specific seeder class by name instead of all seeders.

Examples

Run all seeders against the local database:

bash
npx @orphnet/d1-eloquent seed --db MY_DB --local

Run a single seeder:

bash
npx @orphnet/d1-eloquent seed --db MY_DB --local --seeder UserSeeder

Run all seeders against the remote database:

bash
npx @orphnet/d1-eloquent seed --db MY_DB --remote

Notes

  • Seeder files must be located in src/database/seeders/.
  • When running all seeders, they execute in alphabetical order by filename. Use numeric prefixes to control order when seeders depend on each other — for example: 01_UserSeeder.ts, 02_PostSeeder.ts.
  • Use make:seeder to generate a new seeder file. See Generators.
  • Seeders are not idempotent by default — running them twice may insert duplicate rows. Add your own guard logic (e.g., check row count before inserting) when needed.

Released under the MIT License.