import { MigrationInterface , QueryRunner , Table } from 'typeorm' ; export class ProjectPosts1602725498649 implements MigrationInterface { public async up ( queryRunner ) { await queryRunner . createTable ( new Table ( { name : 'project_posts' , columns : [ { name : 'id' , type : 'uuid' , isPrimary : true , generationStrategy : 'uuid' , default : 'uuid_generate_v4()' , } , { name : 'title' , type : 'varchar' , } , { name : 'content' , type : 'varchar' , isNullable : true , } , { name : 'thumbnail' , type : 'varchar' , isNullable : true , } , { name : 'project_id' , type : 'uuid' , } , { name : 'author_id' , type : 'uuid' , } , { name : 'created_at' , type : 'timestamp' , default : 'now()' , } , { name : 'updated_at' , type : 'timestamp' , default : 'now()' , } , ] , foreignKeys : [ { name : 'ProjectPostAuthor' , referencedTableName : 'users' , referencedColumnNames : [ 'id' ] , columnNames : [ 'author_id' ] , onDelete : 'CASCADE' , onUpdate : 'CASCADE' , } , { name : 'ProjectPost' , referencedTableName : 'projects' , referencedColumnNames : [ 'id' ] , columnNames : [ 'project_id' ] , onDelete : 'CASCADE' , onUpdate : 'CASCADE' , } , ] , } ) ) ; } public async down ( queryRunner ) { await queryRunner . dropTable ( 'project_posts' ) ; } }