File

apps/api/src/migrations/1701936992176-create-confirmation-codes-table.ts

Implements

MigrationInterface

Index

Methods
  • Public Async down
  • Public Async up

Methods

Public Async down
down(queryRunner: QueryRunner)
Parameters :
Name Type Optional
queryRunner QueryRunner No
Returns : Promise<void>
Public Async up
up(queryRunner: QueryRunner)
Parameters :
Name Type Optional
queryRunner QueryRunner No
Returns : Promise<void>
import { MigrationInterface, QueryRunner, Table, TableColumn } from 'typeorm'

export class CreateConfirmationCodesTable1701936992176
  implements MigrationInterface
{
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.createTable(
      new Table({
        name: 'confirmation-codes',
        columns: [
          new TableColumn({
            name: 'id',
            type: 'int',
            isPrimary: true,
            isGenerated: true,
            generationStrategy: 'increment'
          }),
          new TableColumn({
            name: 'code',
            type: 'VARCHAR(7)',
            isNullable: true,
            default: null
          }),
          new TableColumn({
            name: 'createdAt',
            type: 'timestamp',
            default: 'CURRENT_TIMESTAMP',
            isNullable: false
          }),
          new TableColumn({
            name: 'expiresIn',
            type: 'timestamp',
            default: 'CURRENT_TIMESTAMP',
            isNullable: false
          }),
          new TableColumn({
            name: 'userId',
            type: 'int'
          })
        ]
      })
    )
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.dropTable('confirmation-codes')
  }
}

results matching ""

    No results matching ""