Bird
0
0

How can you ensure a migration runs only once and does not reapply in NestJS with TypeORM?

hard📝 Application Q9 of 15
NestJS - Database with TypeORM
How can you ensure a migration runs only once and does not reapply in NestJS with TypeORM?
AYou need to rename migration classes after each run
BTypeORM tracks applied migrations in a special table and skips duplicates
CNestJS automatically deletes migration files after running
DYou must manually comment out migration code after running
Step-by-Step Solution
Solution:
  1. Step 1: Understand migration tracking

    TypeORM stores applied migrations in a table to avoid reapplying them.
  2. Step 2: Eliminate manual or incorrect methods

    Manual commenting, deleting files, or renaming classes are not standard or safe practices.
  3. Final Answer:

    TypeORM tracks applied migrations in a special table and skips duplicates -> Option B
  4. Quick Check:

    Migration tracking table prevents reapplication [OK]
Quick Trick: TypeORM uses a table to track applied migrations [OK]
Common Mistakes:
  • Thinking manual code changes prevent reruns
  • Assuming NestJS deletes migration files automatically
  • Believing renaming classes controls migration runs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes