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() {
initializeGenres();
migrateAccuracyField();
// migrateAccuracyField();
}
// const collections = await Collection.findAll({
// where: {
// posterPath: { [Sequelize.Op.notLike]: '/%' }
// }
// });
// const collections = await Collection.findAll({
// where: {
// posterPath: { [Sequelize.Op.notLike]: '/%' }
// }
// });
// collections.forEach(collection => {
// Media.create({
// mediaable: 'collection',
// mediaableId: collection.id,
// type: 'poster',
// path: collection.posterPath,
// isLocal: true,
// isSelected: true
// })
// });
// collections.forEach(collection => {
// Media.create({
// mediaable: 'collection',
// mediaableId: collection.id,
// type: 'poster',
// path: collection.posterPath,
// isLocal: true,
// isSelected: true
// })
// });
// console.log(collections);
}
// 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);
// }
// }