import { MigrationInterface , QueryRunner , Table } from 'typeorm' ; export class LibraryItem1602299249069 implements MigrationInterface { public async up ( queryRunner ) { await queryRunner . createTable ( new Table ( { name : 'library_item' , columns : [ { name : 'id' , type : 'uuid' , isPrimary : true , generationStrategy : 'uuid' , default : 'uuid_generate_v4()' , } , { name : 'title' , type : 'varchar' , } , { name : 'content' , type : 'text' , isNullable : true , } , { name : 'author_id' , type : 'uuid' , } , { name : 'cover' , type : 'varchar' , isNullable : true , } , { name : 'type' , type : 'varchar' , } , { name : 'status' , type : 'varchar' , } , { name : 'contributor_id' , type : 'uuid' , } , { name : 'created_at' , type : 'timestamp' , default : 'now()' , } , { name : 'updated_at' , type : 'timestamp' , default : 'now()' , } , ] , foreignKeys : [ { name : 'LibraryItemContributor' , referencedTableName : 'users' , referencedColumnNames : [ 'id' ] , columnNames : [ 'contributor_id' ] , onDelete : 'CASCADE' , onUpdate : 'CASCADE' , } , { name : 'LibaryItemAuthor' , referencedTableName : 'authors' , referencedColumnNames : [ 'id' ] , columnNames : [ 'author_id' ] , onDelete : 'CASCADE' , onUpdate : 'CASCADE' , } , ] , } ) ) ; } public async down ( queryRunner ) { await queryRunner . dropTable ( 'library_item' ) ; } }