# Seeding and demo data commands

URL: https://kywi-docs-production.up.railway.app/operating/seeding-and-demo-data-commands
Type: docPage

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.

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

## seed prints the password it just set

Not a hash, not a reset link — the literal password, on stdout, under `Created superadmin user:`. On a hosted platform that is your build log, readable by everyone with access to the project long after the deploy. And the defaults are public knowledge: unset, `KYWI_ADMIN_EMAIL` is `admin@kywi.dev` and `KYWI_ADMIN_PASSWORD` is `admin123`. Set both explicitly, and treat the value as compromised the moment it is printed — rotate it before the URL is shared ([Passwords: change, admin reset, forced reset, lock](/governing/passwords-change-admin-reset-forced-reset-lock/)).

## 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](/developing/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.

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:

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.

## Check which database you are about to seed

Both commands resolve the connection the same way every CLI command does, and the fallback is `postgres://localhost:5432/kywi_dev` — a URL that usually exists on a developer machine. The CLI loads a project-root `.env` first, and a real environment variable wins over the file, so the value you get depends on which directory you are standing in. Pass `DATABASE_URL` on the command line for anything that is not your own laptop.

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](/developing/seeding-structure-as-code/)). A production database is built by running those, not by copying rows.
