⚡ ~/naveed Interview Prep
⚡ Portfolio Home ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 998+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
Senior DevOps / SRE CI/CD Database Migrations & Zero-Downtime Releases Enterprise Azure

Q: A production DB migration succeeds, but the API deployment fails and the DB change isn't backward-compatible. How would you recover safely?

Emergency incident triage and architectural prevention when a database schema migration executes in production, but the API deployment crashes and the schema change cannot be trivially rolled back.

#Database #Migrations #Disaster Recovery #Zero Downtime #Azure
🎙️ Candidate Opening & Architectural Context
"This is a Sev-1 scenario that violates the cardinal rule of continuous delivery: database migrations must always be backward-compatible with the currently running application code. Recovery requires rapid hotfixing or forward migration to minimize downtime."
Advertisement

🛠️ Production Runbook & Step-by-Step Resolution

1

Immediate Triage: Diagnose API Crash & Avoid Destructive Rollback

Do NOT blindly rollback the database if users have already written new transactions, as rolling back could drop columns containing live customer data. Inspect the API boot crash logs to identify the exact schema mismatch.

2

Apply Forward Compatibility Hotfix / Database Bridge View

If a column was renamed, create an alias view or database trigger that maps old column names to new column names, allowing the previous v1 API to continue operating against the v2 schema while the v2 API bug is patched.

-- Creating an alias column or view for temporary backward compatibility
ALTER TABLE users ADD COLUMN legacy_username VARCHAR(255) GENERATED ALWAYS AS (email) STORED;
3

Enforce the Expand/Contract (Parallel Run) Migration Pattern

Mandate that no deployment may ever execute destructive schema changes in Phase 1. Follow the 3-phase rule: 1) Expand (add new columns, dual-write), 2) Deploy app, 3) Contract (drop old columns in a subsequent release).

Pro Tip: Zero-Downtime Principle: Schema changes must be decoupled from application code deployments. Schema first (additive), Code second, Cleanup third.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Never perform destructive database changes in step 1. Use the Expand/Contract pattern so current code can always operate against the updated schema."
⚡ 60-Second Elevator Pitch Talking Points
  • Do not execute destructive database rollbacks that risk dropping live customer data.
  • Create a database compatibility bridge (views, triggers, or default constraints) to support the v1 API.
  • Push an emergency roll-forward hotfix to resolve the API startup exception.
  • Enforce the Expand/Contract deployment pattern: all database migrations must be 100% backward-compatible.
Advertisement
Want more CI/CD scenarios?
Explore our complete collection of scenario-based CI/CD interview runbooks.
Browse All CI/CD Questions →

📚 Related Production Scenarios in CI/CD