refactor: Adds Keyword Table migration to add new fields.

- Adds city, latlong and settings fields to Keyword table.
This commit is contained in:
towfiqi 2024-02-04 23:43:13 +06:00
parent dd54e535c9
commit 444ba5d461
2 changed files with 29 additions and 1 deletions

View File

@ -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 });
});
},
};

View File

@ -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;