What is database seeding
· Category: SQL & Databases
Short answer
Database seeding is the process of populating a database with initial data for development, testing, or demo environments.
How it works
Seeds are scripts or files that insert predefined rows into tables. They differ from migrations because they insert data rather than modify schema. Tools like Prisma, Sequelize, and Laravel offer dedicated seeding commands.
Example
INSERT INTO roles (name) VALUES ('admin'), ('user'), ('guest');
Why it matters
Consistent seed data ensures that all developers and CI pipelines work with a known baseline. It also enables reliable integration tests that depend on specific records.
Common issues
- Running seeds against production databases can overwrite real data if not carefully restricted.
- Foreign key dependencies require seeds to run in the correct order.r