From 4714af0ed136912c230427a898a5299b05f076d8 Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Wed, 13 May 2026 17:09:46 -0700 Subject: [PATCH] Move Author import to upgrade function to prevent potential downgrade issue --- server/migrations/v2.34.0-add-author-search-name.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/migrations/v2.34.0-add-author-search-name.js b/server/migrations/v2.34.0-add-author-search-name.js index ddac8d645..1b691478a 100644 --- a/server/migrations/v2.34.0-add-author-search-name.js +++ b/server/migrations/v2.34.0-add-author-search-name.js @@ -50,7 +50,7 @@ async function removeIndexIfPresent(queryInterface, logger, tableName, indexName await queryInterface.removeIndex(tableName, indexName) } -async function backfillAuthorSearchName(queryInterface, logger, transaction, offset = 0) { +async function backfillAuthorSearchName(queryInterface, logger, transaction, Author, offset = 0) { while (true) { const authors = await queryInterface.sequelize.query(`SELECT id, name FROM ${AUTHORS_TABLE} ORDER BY id ASC LIMIT :limit OFFSET :offset`, { replacements: { limit: 500, offset }, @@ -217,6 +217,7 @@ async function refreshLibraryItemAuthorNames(queryInterface, transaction) { async function up({ context: { queryInterface, logger } }) { logger.info(`${loggerPrefix} UPGRADE BEGIN: ${migrationName}`) + const Author = require('../models/Author') const tableDescription = await queryInterface.describeTable(AUTHORS_TABLE) await queryInterface.sequelize.transaction(async (transaction) => { @@ -250,7 +251,7 @@ async function up({ context: { queryInterface, logger } }) { ) } - await backfillAuthorSearchName(queryInterface, logger, transaction, 0) + await backfillAuthorSearchName(queryInterface, logger, transaction, Author, 0) await mergeDuplicateAuthors(queryInterface, logger, transaction) await cleanupDuplicateBookAuthors(queryInterface, transaction) await refreshLibraryItemAuthorNames(queryInterface, transaction)