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

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.

Tejas Chokhawala Tejas Chokhawala Full-stack engineer with 5 years experience building production web apps using React, Next.js and TypeScript. Focused on performance, clean architecture and shipping fast. Experienced with Supabase/Postgres backends, Stripe billing, and building AI-assisted developer tools. Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : ) Prakash Prajapati Prakash Prajapati I’m a Senior Python Developer specializing in building secure, scalable, and highly available systems. I work primarily with Python, Django, FastAPI, Docker, PostgreSQL, and modern AI tooling such as PydanticAI, focusing on clean architecture, strong design principles, and reliable DevOps practices. I enjoy solving complex engineering problems and designing systems that are maintainable, resilient, and built to scale. BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. 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. Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert Yovel Cohen Yovel Cohen I got a lot of experience in building Long-horizon AI Agents in production, Backend apps that scale to millions of users and frontend knowledge as well. Simon A. Simon A. I'm a backend developer building APIs, emulators, and interactive game systems. Professionally, I've developed Java/Spring reporting solutions, managed relational and NoSQL databases, and implemented CI/CD workflows. Matt Butler Matt Butler Software Engineer @ AWS Anthony Akpan Anthony Akpan Developer with 8 years of experience building softwares fro startups

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