fp/packages/strapi/database/migrations/2024-01-08-add-streams.js.n...

31 lines
1.0 KiB
Plaintext
Raw Normal View History

2024-01-20 16:16:14 +00:00
module.exports = {
async up(knex) {
await knex.schema.createTable('streams', (table) => {
table.increments('id').primary();
table.string('date_str').notNullable();
table.string('vods');
table.string('vtuber');
table.string('tweet');
table.string('date');
table.string('cuid');
});
// Add the 'cdn_url' column to the 'b2_files' table
await knex.schema.table('b2_files', (table) => {
table.string('cdn_url'); // Change the data type if needed (e.g., text, varchar, etc.)
});
// Get all B2 Files from the database
const files = await knex.select('*').from('b2_files');
// For each B2 File, create cdnUrl
for (const [index, file] of files.entries()) {
const key = file.key;
const cdnUrl = `https://futureporn-b2.b-cdn.net/futureporn/${key}`;
await knex('b2_files').update({ cdn_url: cdnUrl }).where({ id: file.id });
}
},
};