Seeding
Seeding is the process of writing generated data into your database. Seedfast does this directly — there's no intermediate format, no file to import, no manual SQL to run.
Direct database writes#
When a seed runs, Seedfast connects to your database and inserts records table by table, in the order determined during the planning phase. Data lands in your tables exactly as it would from your application — as rows in PostgreSQL, immediately queryable.
After seeding, you can use any tool you already use with your database:
- Query with
psqlor any SQL client - Inspect in a GUI like pgAdmin, DBeaver, or TablePlus
- Use immediately for development, testing, or demo environments
- Export to any format if needed
Nothing special is required. The data is just there.
Local and remote databases#
Seedfast seeds local and remote databases using the same workflow. Point it at a connection string — the rest is identical:
# Local
seedfast connect
# prompts for connection string: postgresql://user:pass@localhost:5432/mydb
# Remote — set connection string directly
seedfast connect postgres://user:pass@remote-host:5432/db
seedfast seed --scope "..."
This makes it straightforward to seed staging environments, review app databases, or any remote PostgreSQL instance you have credentials for.
Trigger-aware seeding#
Seedfast accounts for database triggers when inserting data. If your schema has triggers that fire on insert — updating timestamps, maintaining denormalized counters, enforcing business rules — Seedfast handles this correctly.
The data you end up with reflects the actual state of your database after triggers run, not just the raw inserted values. This matches how your application writes data and means the seeded state is consistent with real usage.
Insert order and dependency resolution#
Before any data is written, Seedfast resolves the correct insert order across all tables in scope. Foreign key constraints are never violated — parent records are always inserted before dependent ones.
If your scope includes a table that depends on another table not in scope, Seedfast catches this during the planning phase and asks you to resolve it before seeding starts. You won't discover a dependency failure halfway through a large seed.
What gets seeded#
Only the tables in your scope are touched. Existing rows in those tables are not modified or deleted — Seedfast appends new records.
If you need a clean state before seeding, truncate the relevant tables first:
# DATABASE_URL is your connection string, e.g. postgresql://user:pass@localhost:5432/mydb
psql $DATABASE_URL -c "TRUNCATE users, orders, products RESTART IDENTITY CASCADE;"
seedfast seed --scope "seed 100 users with orders and products"