import { MigrationInterface , QueryRunner , Table , TableForeignKey } from "typeorm" ; export class UserSessions1610180398421 implements MigrationInterface { public async up ( queryRunner ) { await queryRunner . createTable ( new Table ( { columns : [ { isPrimary : true , length : "36" , name : "id" , type : "char" , } , { length : "36" , name : "userId" , type : "char" , } , { default : "now()" , name : "createdAt" , type : "timestamp" , } , { name : "expiresAt" , type : "datetime" , } , ] , name : "userSessions" , } ) ) ; await queryRunner . createForeignKey ( "userSessions" , new TableForeignKey ( { columnNames : [ "userId" ] , referencedColumnNames : [ "id" ] , referencedTableName : "users" , } ) ) ; } public async down ( queryRunner ) { await queryRunner . dropTable ( "userSessions" ) ; } }