diff --git a/database/migrations/1707068556345-add-new-keyword-fields.js b/database/migrations/1707068556345-add-new-keyword-fields.js new file mode 100644 index 0000000..5b9628b --- /dev/null +++ b/database/migrations/1707068556345-add-new-keyword-fields.js @@ -0,0 +1,19 @@ +// Migration: Adds city, latlong and settings keyword to keyword table. + +// CLI Migration +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.sequelize.transaction(async (t) => { + await queryInterface.addColumn('keyword', 'city', { type: Sequelize.DataTypes.STRING }, { transaction: t }); + await queryInterface.addColumn('keyword', 'latlong', { type: Sequelize.DataTypes.STRING }, { transaction: t }); + await queryInterface.addColumn('keyword', 'settings', { type: Sequelize.DataTypes.STRING }, { transaction: t }); + }); + }, + down: (queryInterface) => { + return queryInterface.sequelize.transaction(async (t) => { + await queryInterface.removeColumn('keyword', 'city', { transaction: t }); + await queryInterface.removeColumn('keyword', 'latlong', { transaction: t }); + await queryInterface.removeColumn('keyword', 'settings', { transaction: t }); + }); + }, + }; diff --git a/database/models/keyword.ts b/database/models/keyword.ts index 9c9c1c6..352e8a8 100644 --- a/database/models/keyword.ts +++ b/database/models/keyword.ts @@ -19,7 +19,13 @@ class Keyword extends Model { @Column({ type: DataType.STRING, allowNull: true, defaultValue: 'US' }) country!: string; - @Column({ type: DataType.STRING, allowNull: false }) + @Column({ type: DataType.STRING, allowNull: true, defaultValue: '' }) + city!: string; + + @Column({ type: DataType.STRING, allowNull: true, defaultValue: '' }) + latlong!: string; + + @Column({ type: DataType.STRING, allowNull: false, defaultValue: '{}' }) domain!: string; // @ForeignKey(() => Domain) @@ -58,6 +64,9 @@ class Keyword extends Model { @Column({ type: DataType.STRING, allowNull: true, defaultValue: 'false' }) lastUpdateError!: string; + + @Column({ type: DataType.STRING, allowNull: true }) + settings!: string; } export default Keyword;