import { MigrationInterface , QueryRunner , Table } from 'typeorm' ; export class CreateCustomerTransactionTable1546527306595 implements MigrationInterface { public async up ( queryRunner ) { const table = new Table ( { name : 'customer_transaction' , columns : [ { name : 'customer_transaction_id' , type : 'integer' , length : '11' , isGenerated : true , generationStrategy : 'increment' , isPrimary : true , isNullable : false , } , { name : 'customer_id' , type : 'integer' , length : '11' , isPrimary : false , isNullable : true , } , { name : 'order_id' , type : 'integer' , length : '11' , isPrimary : false , isNullable : false , } , { name : 'description' , type : 'TEXT' , isPrimary : false , isNullable : true , } , { name : 'amount' , type : 'DECIMAL(15,4)' , isPrimary : false , isNullable : true , } , { name : 'is_active' , type : 'int' , length : '11' , isPrimary : false , isNullable : true , } , { name : 'created_by' , type : 'integer' , length : '11' , isPrimary : false , isNullable : true , } , { name : 'modified_by' , type : 'integer' , length : '11' , isPrimary : false , isNullable : true , } , { name : 'created_date' , type : 'DATETIME' , isPrimary : false , isNullable : true , default : 'CURRENT_TIMESTAMP' , } , { name : 'modified_date' , type : 'DATETIME' , isPrimary : false , isNullable : true , default : 'CURRENT_TIMESTAMP' , } , ] , } ) ; const ifExsist = await queryRunner . hasTable ( 'customer_transaction' ) ; if ( ! ifExsist ) { await queryRunner . createTable ( table ) ; } } public async down ( queryRunner ) { await queryRunner . dropTable ( 'customer_transaction' , true ) ; } }