Why use migrations instead of automatic schema sync?
Practice this questionWANT TO UNDERSTAND THE CONCEPT FIRST?Learn Why use migrations instead of automatic schema sync?
Definition:
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.
Key points:
-
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.
Interview point:
- A down migration is not guaranteed to restore deleted data; plan backups and forward fixes where needed.
Adapted from 03_NESTJS.md · “Why use migrations instead of automatic schema sync?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.