UNPKG

@grouparoo/core

Version:
48 lines (47 loc) 2.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const sequelize_1 = require("sequelize"); exports.default = { up: async (queryInterface, DataTypes) => { await queryInterface.addColumn("exports", "state", { type: DataTypes.STRING(191), allowNull: true, }); await queryInterface.bulkUpdate("exports", { state: "failed" }, { state: null, errorMessage: { [sequelize_1.Op.ne]: null } }); await queryInterface.bulkUpdate("exports", { state: "complete" }, { state: null, completedAt: { [sequelize_1.Op.ne]: null } }); await queryInterface.bulkUpdate("exports", { state: "pending" }, { state: null }); await queryInterface.changeColumn("exports", "state", { type: DataTypes.STRING(191), allowNull: false, }); await queryInterface.addColumn("exports", "sendAt", { type: DataTypes.DATE, allowNull: true, }); await queryInterface.bulkUpdate("exports", { sendAt: new Date() }, { state: "pending" }); await queryInterface.addColumn("exports", "retryCount", { type: DataTypes.INTEGER, allowNull: true, }); await queryInterface.bulkUpdate("exports", { retryCount: 0 }, {}); await queryInterface.changeColumn("exports", "retryCount", { type: DataTypes.INTEGER, allowNull: false, }); await queryInterface.addIndex("exports", ["state"], { fields: ["state"], }); await queryInterface.addIndex("exports", ["sendAt"], { fields: ["sendAt"], }); await queryInterface.addIndex("exports", ["completedAt"], { fields: ["completedAt"], }); await queryInterface.removeColumn("exports", "mostRecent"); }, down: async (queryInterface) => { await queryInterface.removeColumn("exports", "state"); await queryInterface.removeColumn("exports", "sendAt"); await queryInterface.removeColumn("exports", "retryCount"); }, };