Database Seed Data Not Loaded on Startup
Seed data script that populates initial test data in development is not executing. The database starts empty, causing tests and manual testing to fail. This might be a timing issue where seed data attempts to load before migrations complete.
Seed data loading is typically optional and failures are silently ignored, making this hard to debug.
Error Messages You Might See
Common Causes
- Seed data script runs before migrations complete, violating foreign key constraints
- Seed data file not in correct location or not discovered by classpath scanner
- Seed data loader bean not initialized due to missing @Component or configuration
- Seed data script has SQL syntax errors silently caught by exception handler
- Database constraints prevent seed inserts (unique violations, type mismatches)
How to Fix It
Run seed data AFTER migration completion by using @Order or @Depends-On annotations. Add explicit logging to confirm seed data loading starts and finishes. Validate SQL scripts manually before inclusion. Use separate seed files for test vs development environments. Include rollback scripts to easily reset data.
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
When should seed data load?
After migrations complete but before tests run. Use @Order annotation to control initialization sequence.
Should seed data load in production?
No. Seed data is only for development/test environments. Gate seed loading behind a configuration flag.
How to validate seed data loaded?
Query counts after startup: SELECT COUNT(*) FROM users. Compare to expected numbers. Add metrics to track seed completion.