backend: removed migrateAccuracyField() function as it was temporary.

This commit is contained in:
X4Lo committed 2026-04-20 20:25:04 +01:00
1 parent 63fdc00ac2
commit 1cc75a94ef
1 file changed
+51 -51
+51 -51
View File
@@ -7,29 +7,29 @@ const Media = require("../models/Media");
async function initializeData() { async function initializeData() {
initializeGenres(); initializeGenres();
migrateAccuracyField(); // migrateAccuracyField();
} }
// const collections = await Collection.findAll({ // const collections = await Collection.findAll({
// where: { // where: {
// posterPath: { [Sequelize.Op.notLike]: '/%' } // posterPath: { [Sequelize.Op.notLike]: '/%' }
// } // }
// }); // });
// collections.forEach(collection => { // collections.forEach(collection => {
// Media.create({ // Media.create({
// mediaable: 'collection', // mediaable: 'collection',
// mediaableId: collection.id, // mediaableId: collection.id,
// type: 'poster', // type: 'poster',
// path: collection.posterPath, // path: collection.posterPath,
// isLocal: true, // isLocal: true,
// isSelected: true // isSelected: true
// }) // })
// }); // });
// console.log(collections); // console.log(collections);
} // }
async function initializeGenres() { async function initializeGenres() {
try { try {
@@ -88,38 +88,38 @@ module.exports = {
initializeGenres, initializeGenres,
} }
async function migrateAccuracyField() { // async function migrateAccuracyField() {
try { // try {
const qi = sequelize.getQueryInterface(); // const qi = sequelize.getQueryInterface();
// Add accuracy column to entrySeens if it doesn't exist // // Add accuracy column to entrySeens if it doesn't exist
const entrySeenColumns = await qi.describeTable('entrySeens'); // const entrySeenColumns = await qi.describeTable('entrySeens');
if (!entrySeenColumns.accuracy) { // if (!entrySeenColumns.accuracy) {
await qi.addColumn('entrySeens', 'accuracy', { // await qi.addColumn('entrySeens', 'accuracy', {
type: Sequelize.ENUM('EXACT', 'ESTIMATED', 'UNKNOWN'), // type: Sequelize.ENUM('EXACT', 'ESTIMATED', 'UNKNOWN'),
defaultValue: 'EXACT', // defaultValue: 'EXACT',
}); // });
// Set all existing records to EXACT // // Set all existing records to EXACT
await sequelize.query(`UPDATE entrySeens SET accuracy = 'EXACT' WHERE accuracy IS NULL`); // await sequelize.query(`UPDATE entrySeens SET accuracy = 'EXACT' WHERE accuracy IS NULL`);
// Set records with date_seen = 2021-01-01 to UNKNOWN // // Set records with date_seen = 2021-01-01 to UNKNOWN
await sequelize.query(`UPDATE entrySeens SET accuracy = 'UNKNOWN' WHERE DATE(date_seen) = '2021-01-01'`); // await sequelize.query(`UPDATE entrySeens SET accuracy = 'UNKNOWN' WHERE DATE(date_seen) = '2021-01-01'`);
console.log('Migrated accuracy field on entrySeens'); // console.log('Migrated accuracy field on entrySeens');
} // }
// Add accuracy column to episodeSeens if it doesn't exist // // Add accuracy column to episodeSeens if it doesn't exist
const episodeSeenColumns = await qi.describeTable('episodeSeens'); // const episodeSeenColumns = await qi.describeTable('episodeSeens');
if (!episodeSeenColumns.accuracy) { // if (!episodeSeenColumns.accuracy) {
await qi.addColumn('episodeSeens', 'accuracy', { // await qi.addColumn('episodeSeens', 'accuracy', {
type: Sequelize.ENUM('EXACT', 'ESTIMATED', 'UNKNOWN'), // type: Sequelize.ENUM('EXACT', 'ESTIMATED', 'UNKNOWN'),
defaultValue: 'EXACT', // defaultValue: 'EXACT',
}); // });
// Set all existing records to EXACT // // Set all existing records to EXACT
await sequelize.query(`UPDATE episodeSeens SET accuracy = 'EXACT' WHERE accuracy IS NULL`); // await sequelize.query(`UPDATE episodeSeens SET accuracy = 'EXACT' WHERE accuracy IS NULL`);
// Set records with date_seen = 2020-01-01 to UNKNOWN // // Set records with date_seen = 2020-01-01 to UNKNOWN
await sequelize.query(`UPDATE episodeSeens SET accuracy = 'UNKNOWN' WHERE DATE(date_seen) = '2020-01-01'`); // await sequelize.query(`UPDATE episodeSeens SET accuracy = 'UNKNOWN' WHERE DATE(date_seen) = '2020-01-01'`);
console.log('Migrated accuracy field on episodeSeens'); // console.log('Migrated accuracy field on episodeSeens');
} // }
} catch (error) { // } catch (error) {
console.error('Error migrating accuracy field:', error); // console.error('Error migrating accuracy field:', error);
} // }
} // }