| Total Complexity | 2 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 | } |
||
| 35 |