Passed
Push — master ( 00c0d4...3c958b )
by Leandro
01:29
created

CreateTokens1625855540929   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 25
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A up 0 23 1
A down 0 3 1
1
import {MigrationInterface, QueryRunner, Table, TableIndex} from "typeorm";
2
3
export class CreateTokens1625855540929 implements MigrationInterface {
4
5
    public async up(queryRunner: QueryRunner): Promise<void> {
6
      await queryRunner.createTable(new Table({
7
        name: "tokens",
8
        columns: [
9
          {
10
            name: "user_id",
11
            type: "varchar(255)",
12
          }, {
13
            name: "token",
14
            type: "varchar(255)",
15
            isPrimary: true,
16
          }, {
17
            name: "created_at",
18
            type: "datetime",
19
            default: "CURRENT_TIMESTAMP",
20
          },
21
        ],
22
      }));
23
24
      await queryRunner.createIndex("tokens", new TableIndex({
25
        name: "ix_tokens_user",
26
        columnNames: ["user_id"],
27
      }));
28
    }
29
30
    public async down(queryRunner: QueryRunner): Promise<void> {
31
      await queryRunner.dropTable("tokens");
32
    }
33
34
}
35