Skip to content

Commit

Permalink
migrate: Add polls migration from dates to timestamps
Browse files Browse the repository at this point in the history
Fixes #1735
  • Loading branch information
sogehige committed Jan 14, 2019
1 parent 8384a44 commit f9bfdda
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tools/migrate.js
Expand Up @@ -160,6 +160,30 @@ let updates = async (from, to) => {
}

let migration = {
polls: [{
version: '8.3.0',
do: async () => {
console.info('[Polls] Fix dates to timestamps')
let items = await global.db.engine.find('systems.polls')
let processed = 0
for (let item of items) {
item.openedAt = (new Date(item.openedAt)).getTime()
item.closedAt = (new Date(item.closedAt)).getTime()
const _id = String(item._id); delete item._id
await global.db.engine.update('systems.polls', { _id }, item)
processed++
}

let item = await global.db.engine.findOne('systems.polls.settings', { key: "_.lastTimeRemind" })
if (item) {
item.value = (new Date(item.value)).getTime()
const _id = String(item._id); delete item._id
await global.db.engine.update('systems.polls.settings', { _id }, item)
processed++
}
console.info(` => ${processed} processed`)
}
}],
compact: [{
version: '8.2.1',
do: async () => {
Expand Down

0 comments on commit f9bfdda

Please sign in to comment.