48 lines
1.0 KiB
JavaScript
48 lines
1.0 KiB
JavaScript
module.exports = {
|
|
/**
|
|
* @param {QueryInterface} queryInterface
|
|
* @param {Sequelize} Sequelize
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async up(queryInterface, Sequelize) {
|
|
/**
|
|
* @type {Transaction}
|
|
*/
|
|
const transaction = await queryInterface.sequelize.transaction();
|
|
try {
|
|
await queryInterface.addColumn(
|
|
'likes',
|
|
'amount',
|
|
{
|
|
type: Sequelize.DataTypes.TEXT,
|
|
},
|
|
{ transaction },
|
|
);
|
|
|
|
await transaction.commit();
|
|
} catch (err) {
|
|
await transaction.rollback();
|
|
throw err;
|
|
}
|
|
},
|
|
/**
|
|
* @param {QueryInterface} queryInterface
|
|
* @param {Sequelize} Sequelize
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async down(queryInterface, Sequelize) {
|
|
/**
|
|
* @type {Transaction}
|
|
*/
|
|
const transaction = await queryInterface.sequelize.transaction();
|
|
try {
|
|
await queryInterface.removeColumn('likes', 'amount', { transaction });
|
|
|
|
await transaction.commit();
|
|
} catch (err) {
|
|
await transaction.rollback();
|
|
throw err;
|
|
}
|
|
},
|
|
};
|