1'use strict';
2
3const { convertMdToHTML } = require('../helpers');
4
5module.exports = {
6 up: async (queryInterface, Sequelize) => {
7 const posts = await queryInterface.sequelize.query(`SELECT Posts.content, Posts.id, Posts.slug from Posts;`)
8 for (const p of posts[0]) { // posts[1] is the query that got executed
9 const html = convertMdToHTML(p.content)
10 const update_query = `UPDATE Posts SET renderedContent='${html}' where id=${p.id};`;
11 console.log(`[*] updating -- ${p.id} -- ${p.slug}`)
12 await queryInterface.sequelize.query(update_query);
13 }
14 },
15
16 down: async (queryInterface, Sequelize) => {
17 return await queryInterface.sequelize.query(`UPDATE Posts SET renderedContent='';`)
18 }
19};
20
21