Remove Author model references from migration script

This commit is contained in:
Nicholas Wallace 2026-05-31 08:43:40 -07:00
parent 2c3e9c8069
commit 76d641db9c

View file

@ -9,9 +9,7 @@ const { Sequelize } = require('sequelize')
* @property {MigrationContext} context - an object containing the migration context.
*/
const Author = require('../models/Author')
const migrationVersion = '2.34.0'
const migrationVersion = '2.35.2'
const migrationName = `${migrationVersion}-add-author-search-name`
const loggerPrefix = `[${migrationVersion} migration]`
const AUTHORS_TABLE = 'authors'
@ -87,7 +85,7 @@ async function removeIndexIfPresent(queryInterface, logger, tableName, indexName
await queryInterface.removeIndex(tableName, indexName)
}
async function backfillAuthorSearchName(queryInterface, logger, transaction, Author, offset = 0) {
async function backfillAuthorSearchName(queryInterface, logger, transaction, 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 },
@ -254,7 +252,6 @@ 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) => {
@ -288,7 +285,7 @@ async function up({ context: { queryInterface, logger } }) {
)
}
await backfillAuthorSearchName(queryInterface, logger, transaction, Author, 0)
await backfillAuthorSearchName(queryInterface, logger, transaction, 0)
await mergeDuplicateAuthors(queryInterface, logger, transaction)
await cleanupDuplicateBookAuthors(queryInterface, transaction)
await refreshLibraryItemAuthorNames(queryInterface, transaction)