0
0
NestJSframework~20 mins

Prisma migrations in NestJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Prisma Migration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens after running prisma migrate dev in a NestJS project?

You run prisma migrate dev in your NestJS project. What is the immediate effect on your database and Prisma client?

AIt applies all existing migrations to the database but does not create new migration files.
BIt only creates a migration file but does not apply it to the database or update the Prisma client.
CIt creates a new migration file, applies it to the database, and updates the Prisma client automatically.
DIt updates the Prisma client without creating migration files or changing the database.
Attempts:
2 left
💡 Hint

Think about what prisma migrate dev does during development to keep your database and client in sync.

📝 Syntax
intermediate
2:00remaining
Which Prisma schema snippet correctly defines a new model for migration?

You want to add a new model Post with an id as primary key and a title field. Which schema snippet is correct for Prisma migrations?

Amodel Post { id Int @id @default(autoincrement()) title String }
Bmodel Post { id Int primaryKey title String }
Cmodel Post { id Int @primary @autoIncrement title String }
Dmodel Post { id Int @key @default(autoincrement) title String }
Attempts:
2 left
💡 Hint

Look for the correct Prisma attributes for primary key and auto-increment.

🔧 Debug
advanced
2:00remaining
Why does prisma migrate deploy fail with 'Migration not found' error?

You deployed your NestJS app and ran prisma migrate deploy on production, but it fails with 'Migration not found' error. What is the most likely cause?

AThe database URL in <code>.env</code> is incorrect and points to a wrong database.
BThe Prisma schema file has syntax errors preventing migration deployment.
CThe Prisma client was not regenerated after schema changes.
DThe migration files were not pushed to the production server or are missing in the migrations folder.
Attempts:
2 left
💡 Hint

Consider what prisma migrate deploy expects to find on the server.

state_output
advanced
2:00remaining
What is the state of the database after running prisma migrate reset?

You run prisma migrate reset in your NestJS project. What happens to your database?

AThe database is dropped, recreated, all migrations are applied fresh, and the Prisma client is regenerated.
BOnly the last migration is rolled back, and the database keeps previous data.
CThe database schema is updated without dropping data, applying only new migrations.
DThe Prisma client is regenerated without changing the database.
Attempts:
2 left
💡 Hint

Think about what 'reset' means for a database in development.

🧠 Conceptual
expert
2:00remaining
Why should you avoid running prisma migrate dev directly on production?

In a NestJS project, why is it recommended to use prisma migrate deploy instead of prisma migrate dev on production environments?

A<code>prisma migrate dev</code> does not apply migrations to the database, so production schema stays outdated.
B<code>prisma migrate dev</code> may create new migration files and prompt for user input, which is unsafe in production automation.
C<code>prisma migrate dev</code> only works with SQLite databases, not production databases like PostgreSQL.
D<code>prisma migrate dev</code> automatically deletes all data in production databases.
Attempts:
2 left
💡 Hint

Consider the differences in behavior and safety between development and production migration commands.