taskManager & recurrent events generation

This commit is contained in:
les
2020-01-30 12:37:19 +01:00
parent 0d83a48452
commit 6ad7fd1d79
21 changed files with 366 additions and 291 deletions

View File

@@ -0,0 +1,19 @@
module.exports = {
up: (queryInterface, Sequelize) => {
// return Promise.resolve(1)
return queryInterface.addColumn('events', 'parentId', {
type: Sequelize.INTEGER,
references: {
model: 'events',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'SET NULL'
})
},
down: (queryInterface, Sequelize) => {
return queryInterface.removeColumn('events', 'parentId')
}
}

View File

@@ -0,0 +1,19 @@
const { event: Event } = require('../api/models')
module.exports = {
up: async (queryInterface, Sequelize) => {
const events = await Event.findAll({})
const promises = events.map(e => {
return e.update({ recurrent: JSON.parse(e.recurrent) })
})
return Promise.all(promises)
},
down: async (queryInterface, Sequelize) => {
const events = await Event.findAll({})
const promises = events.map(e => {
return e.update({ recurrent: JSON.stringify(e.recurrent) })
})
return Promise.all(promises)
}
}

View File

@@ -8,12 +8,6 @@ module.exports = {
},
down: (queryInterface, Sequelize) => {
/*
Add reverting commands here.
Return a promise to correctly handle asynchronicity.
Example:
return queryInterface.dropTable('users');
*/
return queryInterface.removeIndex('users', ['email'])
}
};
}