UNPKG

@tomei/live-price

Version:

Tomei live-price Package

45 lines (36 loc) 1.61 kB
'use strict'; /** @type {import('sequelize-cli').Migration} */ module.exports = { async up(queryInterface, Sequelize) { const transaction = await queryInterface.sequelize.transaction(); try { const tableDescription = await queryInterface.describeTable('price_TomeiPriceHistory'); // Only add CompanyCode column if it doesn't exist if (!tableDescription.CompanyCode) { await queryInterface.addColumn('price_TomeiPriceHistory', 'CompanyCode', { type: Sequelize.STRING(10), allowNull: false, defaultValue: 'CTH', }, { transaction }); await queryInterface.addIndex('price_TomeiPriceHistory', ['CompanyCode'], { transaction }); await queryInterface.addIndex('price_TomeiPriceHistory', ['FeedName', 'Currency', 'CompanyCode'], { transaction }); } await transaction.commit(); } catch (error) { await transaction.rollback(); throw error; } }, async down(queryInterface, Sequelize) { const transaction = await queryInterface.sequelize.transaction(); try { await queryInterface.removeIndex('price_TomeiPriceHistory', ['FeedName', 'Currency', 'CompanyCode'], { transaction }); await queryInterface.removeIndex('price_TomeiPriceHistory', ['CompanyCode'], { transaction }); await queryInterface.removeColumn('price_TomeiPriceHistory', 'CompanyCode', { transaction }); await transaction.commit(); } catch (error) { await transaction.rollback(); throw error; } } };