LESSON 15 / 18·2 min readIntermediate

Why use migrations instead of automatic schema sync?

Try code in the playground
01 Understand02 Recall03 Prepare

Understand the concept

A migration is a versioned database change that can be reviewed and applied deliberately. Automatic schema synchronization tries to match the schema to entity definitions and may make changes without a safe production rollout plan. Migrations make data changes, compatibility and deployment order explicit.

Important ideas

  • Migrations record intentional schema changes that can be reviewed.

  • Automatic sync may make unwanted changes to production data.

  • Plan compatibility between old and new app versions during deployment.

  • Use an expand-and-contract rollout when old and new app versions need to run together during a deployment.

PAUSE & RECALL

Can you explain it without the notes?

Why use migrations instead of automatic schema sync?

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

A migration is a versioned database change that can be reviewed and applied deliberately. Automatic schema synchronization tries to match the schema to entity definitions and may make changes without a safe production rollout plan. Migrations make data changes, compatibility and deployment order explicit.

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

  • A down migration is not guaranteed to restore deleted data; plan backups and forward fixes where needed.
Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: How should Nest handle jobs and scheduled tasks?

Adapted from 03_NESTJS.md · “Why use migrations instead of automatic schema sync?”. Examples are study fragments; framework behavior can depend on your version.