mirror of
https://github.com/towfiqi/serpbear
synced 2025-06-26 18:15:54 +00:00
refactor: Adds Keyword Table migration to add new fields.
- Adds city, latlong and settings fields to Keyword table.
This commit is contained in:
parent
dd54e535c9
commit
444ba5d461
19
database/migrations/1707068556345-add-new-keyword-fields.js
Normal file
19
database/migrations/1707068556345-add-new-keyword-fields.js
Normal 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 });
|
||||
});
|
||||
},
|
||||
};
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user