feat: page locale migration + deps update

This commit is contained in:
Nick
2019-07-14 16:12:26 -04:00
parent 35c09a3602
commit 5689444a17
11 changed files with 735 additions and 892 deletions

View File

@@ -421,6 +421,19 @@ module.exports = class Page extends Model {
return fs.emptyDir(path.join(process.cwd(), `data/cache`))
}
static async migrateToLocale({ sourceLocale, targetLocale }) {
return WIKI.models.pages.query()
.patch({
localeCode: targetLocale
})
.where({
localeCode: sourceLocale
})
.whereNotExists(function() {
this.select('id').from('pages AS pagesm').where('pagesm.localeCode', targetLocale).andWhereRaw('pagesm.path = pages.path')
})
}
static cleanHTML(rawHTML = '') {
return striptags(rawHTML || '')
.replace(emojiRegex(), '')