Millions of users have data in your app local database. How do you change the schema safely?
What the interviewer wants to hear
- Write explicit, versioned migrations for every schema version
- Test migrations from every old version with real-like data
- Avoid destructive fallback unless the data can be fully re-downloaded
- Handle large tables carefully: transactions, batching, startup time
- Plan for failure: backups, telemetry and staged rollout
Model answer
Users can jump from any old version to the newest, so I keep an explicit migration for every version step and test the full chain, for example 3 to 7, not only the last step. Room MigrationTestHelper, Core Data or SwiftData lightweight migrations and SQL scripts for SQLite are verified in automated tests against databases created by real old builds with realistic data. I avoid destructive migrations unless the data is a pure cache that can be fully re-downloaded, because wiping offline edits loses user work. Each migration runs in a transaction so a failure leaves the old data intact. For big tables I watch the time it adds to startup and may migrate lazily or in the background. I log migration failures to telemetry, and I ship schema changes through a staged rollout so a bad migration reaches only a small group before we can halt it.
Can you answer it under time pressure?
Take a timed hard round and get scored on every answer.
More hard Mobile App Developer questions
- How would you design the mobile client for a chat app like WhatsApp?
- Your app has grown to 40 developers and one huge module. Builds are slow and teams block each other. How would you restructure it?
- A delivery app must track the rider location all day. How do you balance accuracy with battery life and OS limits?
- In a Flutter or React Native app, you need a feature that only exists in native SDKs, such as a payment terminal SDK. How would you integrate it well?
- How would you measure and improve app performance for real users in production, not just on your test phone?
- Users keep running old versions of your app for months. How do you evolve the API and decide when to force an update?
- Your crash reports show rising out-of-memory crashes after a release. How do you find and fix the problem?
- How would you implement secure login with an OAuth or OpenID Connect provider in a mobile app?
- How would you migrate a large UIKit or Android View app to SwiftUI or Jetpack Compose without stopping feature work?