Some checks failed
Deploy to production / deploy (push) Failing after 3m14s
- Updated the migration script for the contact_message table to conditionally add or remove columns based on their existence, improving migration safety and preventing errors during deployment. - This change ensures that the migration can be run multiple times without causing issues if the columns already exist or are missing. [force-deploy]
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
const table = { tableName: 'contact_message', schema: 'service' };
|
|
const columns = await queryInterface.describeTable(table);
|
|
|
|
if (!columns.answer) {
|
|
await queryInterface.addColumn(table, 'answer', {
|
|
type: Sequelize.TEXT,
|
|
allowNull: true
|
|
});
|
|
}
|
|
|
|
if (!columns.answered_at) {
|
|
await queryInterface.addColumn(table, 'answered_at', {
|
|
type: Sequelize.DATE,
|
|
allowNull: true
|
|
});
|
|
}
|
|
|
|
if (!columns.is_answered) {
|
|
await queryInterface.addColumn(table, 'is_answered', {
|
|
type: Sequelize.BOOLEAN,
|
|
allowNull: false,
|
|
defaultValue: false
|
|
});
|
|
}
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
const table = { tableName: 'contact_message', schema: 'service' };
|
|
const columns = await queryInterface.describeTable(table);
|
|
|
|
if (columns.answer) {
|
|
await queryInterface.removeColumn(table, 'answer');
|
|
}
|
|
if (columns.answered_at) {
|
|
await queryInterface.removeColumn(table, 'answered_at');
|
|
}
|
|
if (columns.is_answered) {
|
|
await queryInterface.removeColumn(table, 'is_answered');
|
|
}
|
|
}
|
|
};
|