Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Manage schema migrations at scale
00:00
5 left

Manage schema migrations at scale

MediumSQL · PostgreSQL

Problem

How do you manage database schema migrations in a high-scale, production environment?

Using the provided migration metadata, write a query that reports the current production migration health for every service, including services without a production migration.

Output

  1. One row per service with service_name, migration_version, latest_status, failed_step_count, total_step_count, and duration_seconds
  2. Include services without a production run, using NULL migration details and zero step counts
  3. Return the latest production run per service, ordered by service_name ascending

Schema

services
ColumnTypeDescription
service_idPKINTUnique service identifier
service_nameVARCHAR(100)Name of the service
migration_runs
ColumnTypeDescription
run_idPKINTUnique migration run identifier
service_idINTService executing the migration
environmentVARCHAR(20)Deployment environment
migration_versionVARCHAR(50)Migration version identifier
statusVARCHAR(20)Overall migration status
started_atTIMESTAMPMigration start timestamp
completed_atTIMESTAMPMigration completion timestamp
migration_steps
ColumnTypeDescription
step_idPKINTUnique migration step identifier
run_idINTMigration run containing the step
step_nameVARCHAR(100)Migration step name
statusVARCHAR(20)Step execution status
Tablesservicesmigration_runsmigration_steps
Interviewer

Your question is Manage schema migrations at scale. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.