gancio-upstream/server/migrations/20240612110249-task_insteadof_evt_notification.js

57 lines
1.3 KiB
JavaScript

'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up (queryInterface, Sequelize) {
await queryInterface.dropTable('event_notifications')
await queryInterface.createTable('tasks', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
},
status: {
type: Sequelize.ENUM,
values: ['new', 'sent', 'error', 'sending'],
defaultValue: 'new',
index: true
},
error: {
type: Sequelize.TEXT
},
eventId: {
type: Sequelize.INTEGER,
allowNull: true,
references: {
model: 'events',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE'
},
notificationId: {
allowNull: true,
type: Sequelize.INTEGER,
references: {
model: 'notifications',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE'
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
},
async down (queryInterface, Sequelize) {
await queryInterface.dropTable('tasks')
}
};