> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reliantlabs.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Seed realistic Postgres development data from your schema

> Fill your dev Postgres with foreign-key-consistent rows that read like your product: auto-seed on env up, your domain words in vocab.yaml, then db seed reset.

You will replace the `sample_name_1` rows a new Forge project starts with by rows that read like your shop: real product names, sensible prices, reviews with real text and recent dates, without writing seed SQL for the bulk of it.

Forge reads the schema your migrations apply, so it knows every type, foreign key and `CHECK` constraint. What a column means is the one thing it cannot know, and `db/seeds/vocab.yaml` is where you say it.

## Before you begin

* The `shop` project with its `products` and `reviews` tables, from [Add a database table with a CRUD API and pages](https://docs.reliantlabs.io/guides/forge/add-table-crud-api-pages.md).
* Forge v1.6 or later. Inside Reliant, run it as `reliant forge`.
* Docker, for the local stack. No account.

**1. Start the stack and let it seed**

The first `env up` on an empty dev database seeds it:

```bash terminal theme={null}
reliant forge env up dev
```

```text Output (trimmed) theme={null}
[up] auto-seeded 40 rows across 2 tables (products, reviews) — first boot only.
[up]   skip once: --no-seed · never for this project: database.seed.auto: false · choose tables: database.seed.tables in forge.yaml
```

It seeds 20 rows per table, only for your CRUD entities' tables and the tables they require through a foreign key. `--no-seed` skips it for one run.

**2. Look at what it wrote**

`db query` runs one read-only statement against an environment's database:

```bash terminal theme={null}
reliant forge db query dev "select name, price_cents, active from products order by price_cents limit 4"
```

```text theme={null}
name           price_cents  active
sample_name_1  1            true
sample_name_2  2            true
sample_name_3  3            true
sample_name_4  4            false
```

Every row is valid and every review points at a real product. But undescribed text reads `sample_<column>_<n>`, and a numeric column with no `CHECK` seeds as the row number: a price of one cent.

**3. Describe your columns in vocab.yaml**

`db/seeds/vocab.yaml` is yours. Add value pools, numeric ranges and time ranges relative to today:

```yaml db/seeds/vocab.yaml theme={null}
pools:
  product_names: [Chemex Pour-Over, Aeropress Go, Hario Skerton Grinder, Fellow Stagg Kettle, Kalita Wave 185]
columns:
  products.name: {pool: product_names}
  products.price_cents: {min: 1200, max: 24900, step: 100}
  products.active: [true, true, true, false]   # a repeated value weights the draw: about 75% active
  reviews.rating: {min: 1, max: 5}
  reviews.body: ["Brews a clean cup.", "Took a week to dial in.", "Lid rattles, coffee is great.", "Gift for my sister, she loves it."]
  reviews.created_at: {from: -90d, to: now}
```

Each value is checked against the schema; an invalid one is skipped with a warning. Keys cannot be set here: the seeder keeps references consistent itself.

**4. Add the rows a demo needs**

Each column is drawn on its own, so rows are valid but not coherent. Write rows a demo needs in `db/seeds/custom/`, which runs after the generated rows:

```sql db/seeds/custom/demo.sql theme={null}
-- The product every demo opens on.
INSERT INTO products (id, name, price_cents, active) VALUES
    ('demo-chemex-8', 'Chemex 8-Cup Classic', 4900, true)
ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name, price_cents = EXCLUDED.price_cents;
```

**5. Reseed the dev database**

`db seed apply` never changes existing rows. After a vocabulary change, `db seed reset` deletes the rows Forge seeded and seeds again:

```bash terminal theme={null}
reliant forge db seed reset
```

```text theme={null}
Reset and seeded 40 row(s) across 2 table(s):
  products                         20
  reviews                          20
Applied custom overlay demo.sql
```

Rows you or your app created stay, and so does the schema.

**6. Verify the data**

```bash terminal theme={null}
reliant forge db query dev "select name, price_cents, active from products order by name limit 6"
```

```text theme={null}
name                  price_cents  active
Aeropress Go          15200        true
Aeropress Go          5800         true
Aeropress Go          9900         true
Aeropress Go          23000        true
Aeropress Go          15100        true
Chemex 8-Cup Classic  4900         true
```

Names and prices come from your pool and range, and `Chemex 8-Cup Classic` is your custom row. Names repeat because five names cover 20 rows; only a `UNIQUE` column is drawn without repeats. `reliant forge db seed status --dsn <url>` prints row counts per table.

Then run `reliant forge generate`: the frontend's [mock mode](https://docs.reliantlabs.io/guides/forge/build-ui-before-backend-mock-mode.md) serves the same rows from fixtures that pick up a vocabulary change only on generate.

## What this does not do

* **No seeding outside dev.** `apply` and `reset` refuse every other environment, and the seeder is not in your server binary.
* **No coherent rows from vocab.yaml.** A review's text is unrelated to its rating; rows that must agree belong in `db/seeds/custom/`.

## Troubleshooting

> [accordion] database connection string required: pass --dsn or set DATABASE\_URL
>
> `db seed status` needs the database named. Pass `--dsn` with the `DATABASE_URL` from `reliant forge env config dev`.

> [accordion] apply refuses and prints COMMENT ON CONSTRAINT ... IS 'forge:ref ...'
>
> A table reaches one parent through two foreign keys. Decide which route is the truth, add the printed statement in a migration, and seed again.

## Next steps

> [card] [Build the UI before the backend](https://docs.reliantlabs.io/guides/forge/build-ui-before-backend-mock-mode.md)
>
> Serve the same rows to the frontend with no API running

> [card] [Test against real Postgres](https://docs.reliantlabs.io/guides/forge/test-go-api-real-postgres.md)
>
> Run handler tests on a real database

> [card] [Adding a feature](https://docs.reliantlabs.io/forge/adding-features.md)
>
> The everyday loop: services, RPCs, migrations, the gate

> [card] [forge CLI](https://docs.reliantlabs.io/cli/forge.md)
>
> Every `reliant forge` command


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.