Claude Code database

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

Migration failed: syntax error in SQL migration Column 'new_field' doesn't exist Table migration_history is locked Cannot execute DDL statements
Migration failed: syntax error in SQL migrationColumn 'new_field' doesn't existTable migration_history is lockedCannot execute DDL statements

Common Causes

  1. Migration file not in correct directory (e.g., db/migration/ vs db/migrations/)
  2. Migration filename doesn't follow version naming convention (V001__ vs V1__)
  3. Migration has syntax errors that are caught but not reported until runtime
  4. Database user lacks DDL permissions to create tables/columns
  5. 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.

Richard McSorley Richard McSorley Full-Stack Software Engineer with 8+ years building high-performance applications for enterprise clients. Shipped production systems at Walmart (4,000+ stores), Cigna (20M+ users), and Arkansas Blue Cross. 5 patents in retail/supply chain tech. Currently focused on AI integrations, automation tools, and TypeScript-first architectures. prajwalfullstack prajwalfullstack Hi Im a full stack developer, a vibe coded MVP to Market ready product, I'm here to help Anthony Akpan Anthony Akpan Developer with 8 years of experience building softwares fro startups Milan Surelia Milan Surelia Milan Surelia is a Mobile App Developer with 5+ years of experience crafting scalable, cross-platform apps at 7Span and Meticha. At 7Span, he engineers feature-rich Flutter apps with smooth performance and modern UI. As the Co-Founder of Meticha, he builds open-source tools and developer-focused products that solve real-world problems. Expertise: 💡 Developing cross-platform apps using Flutter, Dart, and Jetpack Compose for Android, iOS, and Web. 🖋️ Sharing insights through technical writing, blogging, and open-source contributions. 🤝 Collaborating closely with designers, PMs, and developers to build seamless mobile experiences. Notable Achievements: 🎯 Revamped the Vepaar app into Vepaar Store & CRM with a 2x performance boost and smoother UX. 🚀 Launched Compose101 — a Jetpack Compose starter kit to speed up Android development. 🌟 Open source contributions on Github & StackOverflow for Flutter & Dart 🎖️ Worked on improving app performance and user experience with smart solutions. Milan is always happy to connect, work on new ideas, and explore the latest in technology. Bastien Labelle Bastien Labelle Full stack dev w/ 20+ years of experience Franck Plazanet Franck Plazanet I am a Strategic Engineering Leader with over 8 years of experience building high-availability enterprise systems and scaling high-performing technical teams. My focus is on bridging the gap between complex technology and business growth. Core Expertise: 🚀 Leadership: Managing and coaching teams of 15+ engineers, fostering a culture of accountability and continuous improvement. 🏗️ Architecture: Enterprise Core Systems, Multi-system Integration (ERP/API/ETL), and Core Database Structure. ☁️ Cloud & Scale: AWS Expert; architected systems handling 10B+ monthly requests and managing 100k+ SKUs. 📈 Business Impact: Aligning tech strategy with P&L goals to drive $70k+ in monthly recurring revenue. I thrive on "out-of-the-box" thinking to solve complex technical bottlenecks and am always looking for ways to use automation to improve business productivity. Matthew Jordan Matthew Jordan I've been working at a large software company named Kainos for 2 years, and mainly specialise in Platform Engineering. I regularly enjoy working on software products outside of work, and I'm a huge fan of game development using Unity. I personally enjoy Python & C# in my spare time, but I also specialise in multiple different platform-related technologies from my day job. Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems Matt Butler Matt Butler Software Engineer @ AWS

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently 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.

Related Claude Code Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help