import { MigrationInterface , QueryRunner , Table } from 'typeorm' ; export class PostLikes1602113901819 implements MigrationInterface { public async up ( queryRunner ) { await queryRunner . createTable ( new Table ( { name : 'post_likes' , columns : [ { name : 'id' , type : 'uuid' , isPrimary : true , generationStrategy : 'uuid' , default : 'uuid_generate_v4()' , } , { name : 'user_id' , type : 'uuid' , } , { name : 'post_id' , type : 'uuid' , } , ] , foreignKeys : [ { name : 'LikeAuthor' , referencedTableName : 'users' , referencedColumnNames : [ 'id' ] , columnNames : [ 'user_id' ] , onDelete : 'CASCADE' , onUpdate : 'CASCADE' , } , { name : 'PostLiked' , referencedTableName : 'posts' , referencedColumnNames : [ 'id' ] , columnNames : [ 'post_id' ] , onDelete : 'CASCADE' , onUpdate : 'CASCADE' , } , ] , } ) ) ; } public async down ( queryRunner ) { await queryRunner . dropTable ( 'post_likes' ) ; } }