mailtrain/setup/knex/migrations/20180111120444_upgrade_templates.js
Tomas Bures 6706d93bc1 Basic support for Mosaico templates.
TODO:
- Allow choosing a mosaico template in a mosaico-based template
- Integrate the custom mosaico templates with templates (endpoint for retrieving a mosaico template, replacement of URL_BASE and PLACEHOLDER tags
- Implement support for MJML-based Mosaico templates
- Implement support for MJML-based templates
- Implement support for GrapeJS-based templates
2018-04-02 19:05:22 +02:00

27 lines
761 B
JavaScript

exports.up = (knex, Promise) => (async() => {
await knex.schema.table('templates', table => {
table.text('data', 'longtext');
table.string('type');
});
const templates = await knex('templates');
for (const template of templates) {
let type = template.editor_name;
const data = JSON.parse(template.editor_data || '{}');
if (type == 'summernote') {
type = 'ckeditor';
}
await knex('templates').where('id', template.id).update({type, data: JSON.stringify(data)});
}
await knex.schema.table('templates', table => {
table.dropColumn('editor_name');
table.dropColumn('editor_data');
});
})();
exports.down = (knex, Promise) => (async() => {
})();