Seed data for dev and test: realistic without real customers
Short answer: Seed data is the starter content a script loads into a development or test database: a few customers, products, orders and edge cases that let you use and test the app straight away. Write it as a script in the repository, generate realistic-looking but fake people with a library such as Faker, use a fixed random seed so results are repeatable, and use reserved addresses like example.com so nobody real gets an email. Avoid copying production data.
Why an empty database slows everyone down
A fresh local or test database has tables and nothing in them. To check a bug in the order screen, a developer first creates an account, adds products, places a few orders and changes their status. Every developer does this differently, and nobody creates the awkward cases that cause real bugs, like a customer with a 60-character surname or an order with a refunded item.
The common shortcut, copying the production database, solves that and creates a bigger problem: real customers' names, addresses and order histories end up on laptops and test servers with weaker protection. A good seed script gives you the usefulness without the risk.
What good seed data includes
Aim for a small, deliberate set rather than thousands of random rows:
- Known accounts for each role, such as an admin, a staff member and a regular customer, with documented local-only passwords.
- Typical records: a handful of products, customers and orders in different states.
- Edge cases you've been burned by: long names, accented characters, an empty basket, a discount that takes the total to zero, an order with no delivery address.
- Time-based cases: an expired subscription, an appointment tomorrow, an invoice overdue by 31 days.
- Enough volume to spot slow pages, for example a few hundred orders, if list pages matter.
Write down why each edge case is there. It turns the seed script into a record of past bugs.
Use your framework's seeding tools
Most web frameworks have a seeding mechanism, and using it means others on the team already know where to look:
- Laravel has seeder classes run by
php artisan db:seed, can use model factories, and supportsmigrate:fresh --seed, which its documentation says drops all tables, re-runs all migrations and then seeds. - Prisma runs a seed command you define when you call
prisma db seed. Its documentation notes that automatic seeding duringmigrate devandmigrate resethas been removed in recent versions, so you run it explicitly. - Rails, Django and others have their own equivalents, such as seed files and fixtures.
Whatever the tool, the goal is one command that produces a ready-to-use database from nothing.
Generate fake people that look real
Hand-typed "Test User 1" data hides layout bugs, because real names and addresses vary far more. Libraries like Faker generate plausible names, addresses, phone numbers and text in many locales.
Two details matter:
- Fix the random seed. Faker's documentation shows that calling
faker.seed(123)makes the sequence repeatable, so the same script produces the same data each run. That keeps tests stable and lets developers say "customer 14" and mean the same record. The docs also warn that a new Faker version may produce different values for the same seed, so don't hard-code generated values in tests. - Mix generated and hand-written records. Generate the bulk, and hand-write the edge cases you specifically need.
Make sure nobody real is contacted
Seed data with plausible emails and phone numbers can do real damage if a test environment sends messages. Protect against it:
- Use reserved domains. RFC 2606 reserves
example.com,example.netandexample.org, and top-level names such as.test,.exampleand.invalid, which will never belong to a real recipient. - Use phone numbers your provider documents for testing, or clearly invalid ones.
- Route all outgoing email in development to a local mail catcher.
- Point payment integrations at sandbox mode only.
Keep seeds idempotent and current
Two habits stop seed scripts from rotting:
- Make them safe to re-run. Either reset the database first, or check whether a record exists before inserting it, so running the script twice doesn't create duplicates or fail.
- Run them in CI. If a migration adds a required column and the seed script isn't updated, CI fails straight away instead of the next new developer discovering it.
Treat changes to the seed script like any other code change, reviewed with the feature that needs them.
Different data for different jobs
You may want more than one seed set:
| Purpose | What it needs |
|---|---|
| Local development | Small, varied, quick to load |
| Automated tests | Minimal, created per test where possible |
| Demo or sales environment | Polished, believable, no edge-case oddities |
| Performance testing | Large volumes, generated |
Automated tests often work better creating exactly the records each test needs, with factories, rather than relying on one big shared seed.
A worked example
Picture a hypothetical Vancouver physiotherapy clinic's booking app. Developers had been working from an old production copy with real patient names. The team deleted those copies and wrote a seed script: three staff roles, forty generated patients with a fixed Faker seed, appointments spread across past and future weeks, a cancelled series, a patient with a hyphenated double surname and one with only a single name. All emails used example.com, and the mail catcher caught everything. Two layout bugs surfaced in the first week from the generated long names.
FAQ
Can't we just anonymise a production copy?
It's possible but harder than it sounds, because personal details hide in notes, free-text fields and logs. A seed script avoids the risk entirely for most work.
How much data should the seed create?
Enough to use every main screen and see realistic lists. For most apps that's dozens to a few hundred records, loading in seconds.
Should seed passwords be in the repository?
Only clearly local-only, throwaway passwords, documented as such. Never reuse them anywhere real.
Do seeds belong in production?
Only reference data the app needs to run, such as a list of countries, and that's better handled by migrations.
If your developers work from production copies or an empty database, ask us to build a seed set for your app.