How would you migrate a Spring Boot application to a new database schema without downtime?

Migrating a live Spring Boot application to a new database schema without downtime requires a phased, dual-write approach where both schemas coexist temporarily while data and traffic are gradually shifted over.

Key Points

Example

An e-commerce team migrating order storage to a new schema runs dual-writes for two weeks, compares row counts and checksums daily, then cuts reads over to the new schema before finally dropping the old tables.

-- Flyway "expand and contract": every step works with both old and new code

-- V7__expand_add_full_name.sql  (deploy 1: add, don't remove anything)
ALTER TABLE customer ADD COLUMN full_name VARCHAR(200);
UPDATE customer SET full_name = CONCAT(first_name, ' ', last_name);

-- Application version N+1 writes BOTH old and new columns, reads the new one.

-- V8__contract_drop_old_columns.sql  (deploy 2, after all instances run N+1)
ALTER TABLE customer DROP COLUMN first_name;
ALTER TABLE customer DROP COLUMN last_name;

# application.yml: Flyway runs pending migrations at startup
spring:
  flyway:
    enabled: true
    locations: classpath:db/migration

Interview Tip

A concise interview answer is

For a zero-downtime schema migration, I run the old and new schemas in parallel, dual-writing to both while backfilling historical data into the new one. Once I've verified consistency, I switch reads to the new schema, keep dual-writes as a safety net for a while, then decommission the old schema.

Last updated: 11 November 2026

Previous question: Describe a scenario where you would use asynchronous messaging in a Spring Boot application.

Next question: How do you set up logging in Spring Boot?

More Spring Boot - Level IV (Advanced) interview questions

All Spring Boot - Level IV (Advanced) questions