0
0
NestJSframework~10 mins

Migrations in NestJS - Interactive Code Practice

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

Complete the code to import the migrations module in NestJS.

NestJS
import { [1] } from '@nestjs/typeorm';
Drag options to blanks, or click blank then click option'
ATypeOrmModule
BMigrationService
CMigrationsModule
DMigrationModule
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent module like MigrationService.
Confusing MigrationModule with TypeOrmModule.
2fill in blank
medium

Complete the code to configure migrations in the TypeOrmModule.

NestJS
TypeOrmModule.forRoot({
  migrations: ["[1]"],
  migrationsRun: true,
});
Drag options to blanks, or click blank then click option'
Amigrations/*.js
Bmigrations/*.ts
CMigrationFiles
DMigrationScripts
Attempts:
3 left
💡 Hint
Common Mistakes
Using TypeScript files path instead of JavaScript.
Using undefined variables like MigrationFiles.
3fill in blank
hard

Fix the error in the migration class name to follow NestJS migration conventions.

NestJS
export class [1] implements MigrationInterface {
  async up(queryRunner: QueryRunner): Promise<void> {
    // migration code
  }
  async down(queryRunner: QueryRunner): Promise<void> {
    // revert code
  }
}
Drag options to blanks, or click blank then click option'
Acreateusertable
BcreateUserTable
Ccreate_user_table
DCreateUserTable
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase or snake_case for class names.
Starting class names with lowercase letters.
4fill in blank
hard

Fill both blanks to correctly run migrations using the CLI command.

NestJS
npm run [1] -- [2]
Drag options to blanks, or click blank then click option'
Atypeorm
Bmigration:run
Cstart
Dbuild
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' or 'build' instead of 'migration:run'.
Using wrong npm script names.
5fill in blank
hard

Fill all three blanks to create a migration file with the correct CLI command and naming.

NestJS
npm run [1] -- [2] [3]
Drag options to blanks, or click blank then click option'
Atypeorm
Bmigration:create
CAddProductsTable
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' instead of 'typeorm' for the npm script.
Using 'migration:run' instead of 'migration:create'.
Using lowercase or snake_case for migration names.