serpbear/database/migrations/1709217223856-add-keyword-volume-field copy.js
towfiqi 2a1fc0e43d feat: Adds keyword search volume data feature for tracked keywords.
- Adds a volume field in the keyword table.
- Adds a button in the Adwords Integration screen to update all the tracked keywords.
- When a new keyword is added, the volume data is automatically fetched.
- Adds ability to sort keywords based on search volume.
2024-03-01 10:52:45 +06:00

36 lines
1.2 KiB
JavaScript

// Migration: Adds volume field to the keyword table.
// CLI Migration
module.exports = {
up: async (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction(async (t) => {
try {
const keywordTableDefinition = await queryInterface.describeTable('keyword');
if (keywordTableDefinition) {
if (!keywordTableDefinition.volume) {
await queryInterface.addColumn('keyword', 'volume', {
type: Sequelize.DataTypes.STRING, allowNull: false, defaultValue: 0,
}, { transaction: t });
}
}
} catch (error) {
console.log('error :', error);
}
});
},
down: (queryInterface) => {
return queryInterface.sequelize.transaction(async (t) => {
try {
const keywordTableDefinition = await queryInterface.describeTable('keyword');
if (keywordTableDefinition) {
if (keywordTableDefinition.volume) {
await queryInterface.removeColumn('keyword', 'volume', { transaction: t });
}
}
} catch (error) {
console.log('error :', error);
}
});
},
};