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

src/migrations/1625855540929-CreateTokens.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 35
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 26
mnd 0
bc 0
fnc 2
dl 0
loc 35
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A CreateTokens1625855540929.up 0 23 1
A CreateTokens1625855540929.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