Skip to content

Seeding and demo data commands

Two commands bootstrap a database: seed writes the site row, a superAdmin and a home page, and prints the password it just set to stdout.

kywi seed writes four things into an empty, migrated database and skips any that already exist: the site row (slug taken from config.sites[0].id), a superAdmin user, an "Administrators" group with that user in it, and the root page. The site, user and home-page skips each print an … already exists — skipping. line, so a re-run says what it did nothing about — except for the group: finding an existing "Administrators" group is silent, so a re-run gives no confirmation that step ran at all.

bash
DATABASE_URL=postgres://user:pass@host:5432/db \
KYWI_ADMIN_EMAIL=ops@example.com \
KYWI_ADMIN_PASSWORD="$(openssl rand -base64 24)" \
  pnpm exec kywi seed

What the root page is

path: '/', depth 0, type page, in the nav, and published — carrying Welcome to Kywi CMS / Your site is ready. A fresh deploy therefore serves that publicly from the first request, which is fine on a staging host and is not what you want pointed at a domain someone might visit.

seed only knows about the first configured site

It reads config.sites[0] and nothing else, so it is not the way to add a second site — kywi migrate reconciles configured sites and gives each one a published home page (One config, several sites). Two of its lookups are also unscoped: the "Administrators" group is matched by name alone, and the root page by the slug home alone, with no site predicate. On a database that already holds a home row for any site, seed reports Root content "home" already exists — skipping. and the site it just created has no root page at all.

seed:demo is for a demo site

It layers reference content on top of the base seed: pages and blog posts, an event, a contact form, categories and tags, a cover image, a personalization demo (a "Paid Traffic" audience on utm_source=google, an Offers page with a variant for it, and a French About sibling), a kitchen-sink theme styleguide at /styleguide/, and a recent-posts feed. It also rewrites the Home node's title metadata, summary and body in place. Run it on a database whose content you are willing to lose.

bash
DATABASE_URL=postgres://user:pass@host:5432/db pnpm exec kywi seed:demo

It refuses to run before kywi seed has, by name, exiting 1:

text
seed:demo — site "<slug>" not found. Run `kywi seed` first.
seed:demo — Home page not found. Run `kywi seed` first.

Idempotence here is per block, not per run: the content tree, the personalization demo, the styleguide and the feed each have their own guard and each print their own already present, skipping line. A run interrupted halfway leaves the blocks it finished in place, and the next run resumes at the first unguarded one. The demo cover image is the one part that will not work outside the Kywi monorepo — its destination is derived from the CLI's own location (apps/reference/uploads) rather than from config.media.localPath. When that fails you get a warning and demo content without a featured image, not a failed run.

Neither command moves content between environments. Everything above the four base rows — types, pages, layouts, menus, media — is the project's own idempotent scripts, run against the target with an admin token (Seeding structure as code). A production database is built by running those, not by copying rows.