taskManager & recurrent events generation
This commit is contained in:
19
server/migrations/20200127101541-event_parent.js
Normal file
19
server/migrations/20200127101541-event_parent.js
Normal 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')
|
||||
}
|
||||
}
|
||||
19
server/migrations/20200127113535-fix_recurrent.js
Normal file
19
server/migrations/20200127113535-fix_recurrent.js
Normal 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)
|
||||
}
|
||||
}
|
||||
@@ -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'])
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user