Database Migration Silently Fails, Schema Mismatch
A new database migration file was created but didn't execute when starting the application. The database schema remains out of sync with the application code, causing runtime errors when trying to access new columns or tables.
This occurs when migration tools (Flyway, Liquibase) don't detect the new file, have incorrect naming conventions, or encounter permission issues during execution.
Error Messages You Might See
Common Causes
- Migration file not in correct directory (e.g., db/migration/ vs db/migrations/)
- Migration filename doesn't follow version naming convention (V001__ vs V1__)
- Migration has syntax errors that are caught but not reported until runtime
- Database user lacks DDL permissions to create tables/columns
- Migration previously failed, blocking subsequent migrations from running
How to Fix It
Verify migration files are in src/main/resources/db/migration/. Use correct Flyway naming: VX__description.sql. Check database user permissions with CREATE TABLE, ALTER TABLE. Review migration logs in the database metadata table. Use 'repair' command carefully only after fixing failed migrations.
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
What's the correct migration file naming?
Use Flyway convention: V<version>__<description>.sql (e.g., V2__add_user_profile.sql). Versions must be unique and increasing.
How to recover from failed migrations?
Check the migration history table. Create a new migration (V3__fix_previous_error.sql) to correct the issue. Never modify old migrations.
Why does development still work but production fails?
Dev might auto-recreate schema, production uses existing schema. Always test migrations on a copy of production data.