mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-07 09:51:37 +00:00
Remove Author model references from migration script
This commit is contained in:
parent
2c3e9c8069
commit
76d641db9c
1 changed files with 3 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue