Skip to main content
Populate the database across every module with talos seed:run. The command runs each module’s bin/seed/run.ts script from the module’s own directory. Each runner resolves every registered seed, keeps the ones that are active and target the current environment, and runs them in dependency order.
# Run all seeds
talos seed:run

# Clear seeded data first, running in the test environment
talos seed:run --drop --env=test

# Force every seed to run, ignoring the cache
talos seed:run --no-cache
OptionDescriptionDefault
--dropClear seeded data before running seeds.false
--envValue used for APP_ENV when running the seeds.
--no-cacheSkip reading and writing the seed cache.false

How a run proceeds

The runner loads every registered seed and filters it through isActive() and getEnv() against the current APP_ENV. For each remaining seed it first runs the seed’s dependencies — resolving each from the container and collecting their return values — then calls the seed’s run(data) with those values. A seed that throws stops the run and exits non-zero; the runner closes the registered database connection on the way out. There is no tracking table: whether a seed has already run is recorded only by the run cache, so a successful, unchanged seed is skipped on the next run and reported as up to date (cached).

Clearing data

Passing --drop clears seeded data before any seed runs by calling drop() on the module’s registered database constant, then re-seeds from scratch. A module without a registered database simply has nothing to drop. --drop also bypasses the cache, since the reset must always re-seed.

Setting the environment

--env sets APP_ENV for the run, which drives two things: the getEnv() filter that selects which seeds run, and the environment folded into each seed’s cache fingerprint. Seeding a different environment is therefore always a cache miss.

Running run() directly

Outside the CLI you can call run() from @talosjs/seeds:
import { run } from "@talosjs/seeds";

await run();
See the seed:run command for the full reference.

Next steps

  • Caching: how the per-seed run cache skips unchanged seeds.
  • Writing seeds: gate a seed by activity, environment, and dependencies.