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
+35 -35
+35 -35
View File
@@ -7,7 +7,7 @@ const Media = require("../models/Media");
async function initializeData() {
initializeGenres();
migrateAccuracyField();
// migrateAccuracyField();
}
@@ -29,7 +29,7 @@ async function initializeData() {
// });
// console.log(collections);
}
// }
async function initializeGenres() {
try {
@@ -88,38 +88,38 @@ module.exports = {
initializeGenres,
}
async function migrateAccuracyField() {
try {
const qi = sequelize.getQueryInterface();
// async function migrateAccuracyField() {
// try {
// const qi = sequelize.getQueryInterface();
// Add accuracy column to entrySeens if it doesn't exist
const entrySeenColumns = await qi.describeTable('entrySeens');
if (!entrySeenColumns.accuracy) {
await qi.addColumn('entrySeens', 'accuracy', {
type: Sequelize.ENUM('EXACT', 'ESTIMATED', 'UNKNOWN'),
defaultValue: 'EXACT',
});
// Set all existing records to EXACT
await sequelize.query(`UPDATE entrySeens SET accuracy = 'EXACT' WHERE accuracy IS NULL`);
// 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'`);
console.log('Migrated accuracy field on entrySeens');
}
// // Add accuracy column to entrySeens if it doesn't exist
// const entrySeenColumns = await qi.describeTable('entrySeens');
// if (!entrySeenColumns.accuracy) {
// await qi.addColumn('entrySeens', 'accuracy', {
// type: Sequelize.ENUM('EXACT', 'ESTIMATED', 'UNKNOWN'),
// defaultValue: 'EXACT',
// });
// // Set all existing records to EXACT
// await sequelize.query(`UPDATE entrySeens SET accuracy = 'EXACT' WHERE accuracy IS NULL`);
// // 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'`);
// console.log('Migrated accuracy field on entrySeens');
// }
// Add accuracy column to episodeSeens if it doesn't exist
const episodeSeenColumns = await qi.describeTable('episodeSeens');
if (!episodeSeenColumns.accuracy) {
await qi.addColumn('episodeSeens', 'accuracy', {
type: Sequelize.ENUM('EXACT', 'ESTIMATED', 'UNKNOWN'),
defaultValue: 'EXACT',
});
// Set all existing records to EXACT
await sequelize.query(`UPDATE episodeSeens SET accuracy = 'EXACT' WHERE accuracy IS NULL`);
// 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'`);
console.log('Migrated accuracy field on episodeSeens');
}
} catch (error) {
console.error('Error migrating accuracy field:', error);
}
}
// // Add accuracy column to episodeSeens if it doesn't exist
// const episodeSeenColumns = await qi.describeTable('episodeSeens');
// if (!episodeSeenColumns.accuracy) {
// await qi.addColumn('episodeSeens', 'accuracy', {
// type: Sequelize.ENUM('EXACT', 'ESTIMATED', 'UNKNOWN'),
// defaultValue: 'EXACT',
// });
// // Set all existing records to EXACT
// await sequelize.query(`UPDATE episodeSeens SET accuracy = 'EXACT' WHERE accuracy IS NULL`);
// // 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'`);
// console.log('Migrated accuracy field on episodeSeens');
// }
// } catch (error) {
// console.error('Error migrating accuracy field:', error);
// }
// }