Reproducible local data
A seed is a script (SQL or code) that populates a fresh database with reasonable test data. Every developer running the project gets the same starting state — same usernames, same products, same edge cases.
Two patterns
- Static SQL seed: a
seed.sqlwith INSERTs. Simple, deterministic, easy to commit to git. - Programmatic seed: a script that generates data (Faker, Mimesis, your model factories). Better for variety and volume; harder to reproduce exactly.
The idempotency win
Make seeds idempotent — re-running shouldn't crash. ON CONFLICT DO NOTHING for fixed-id rows; truncate-then-reload for everything else (in dev only). Anything you wouldn't dare run twice will eventually be run twice.