fp/packages/strapi/database/migrations/2023-08-17-reformat-cdnUrl.js

18 lines
599 B
JavaScript
Raw Normal View History

2024-01-20 16:16:14 +00:00
module.exports = {
async up(knex) {
// Get all B2 Files from the database
const files = await knex.select('*').from('b2_files');
// For each B2 File, update cdnUrl
// we do this to change
// erroneous https://futureporn-b2.b-cdn.net/futureporn/:key
// to https://futureporn-b2.b-cdn.net/:key
for (const [index, file] of files.entries()) {
const key = file.key;
const cdnUrl = `https://futureporn-b2.b-cdn.net/${key}`;
await knex('b2_files').update({ cdn_url: cdnUrl }).where({ id: file.id });
}
},
};