0
0
NextJSframework~10 mins

Database migrations in NextJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new migration file using Prisma CLI.

NextJS
npx prisma migrate [1] --name init
Drag options to blanks, or click blank then click option'
Arun
Bsave
Cgenerate
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' instead of 'create' to make a migration file.
Confusing 'save' or 'generate' with migration commands.
2fill in blank
medium

Complete the code to apply all pending migrations to the database.

NextJS
npx prisma migrate [1]
Drag options to blanks, or click blank then click option'
Adev
Bdeploy
Cdeployments
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'create' instead of 'deploy' to apply migrations.
Trying 'deployments' which is not a valid command.
3fill in blank
hard

Fix the error in the migration command to reset the database and apply migrations.

NextJS
npx prisma migrate [1] --force
Drag options to blanks, or click blank then click option'
Asave
Bdeploy
Creset
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'deploy' or 'create' instead of 'reset' to reset the database.
Forgetting the '--force' flag when resetting.
4fill in blank
hard

Fill both blanks to write a Prisma schema model with an auto-incrementing ID and a string field.

NextJS
model User {
  id   Int    @id @default([1]())
  name String @[2]
}
Drag options to blanks, or click blank then click option'
Adefault
Bunique
Cautoincrement
Drequired
Attempts:
3 left
💡 Hint
Common Mistakes
Using '@default' instead of '@autoincrement' for ID.
Using '@required' which is not a Prisma decorator.
5fill in blank
hard

Fill all three blanks to write a migration script that creates a table with a primary key and a timestamp.

NextJS
CREATE TABLE [1] (
  id SERIAL PRIMARY KEY,
  created_at [2] DEFAULT [3]
);
Drag options to blanks, or click blank then click option'
Ausers
BTIMESTAMP
CCURRENT_TIMESTAMP
DVARCHAR(255)
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong data types for timestamp.
Forgetting to set default value for created_at.