Remove index creation from migration file

This commit is contained in:
advplyr 2023-09-05 15:36:19 -05:00
parent 05b1b2be36
commit adccccbd7a

View File

@ -1620,12 +1620,11 @@ async function migrationPatch2BookSeries(ctx, offset = 0) {
*/ */
module.exports.migrationPatch2 = async (ctx) => { module.exports.migrationPatch2 = async (ctx) => {
const queryInterface = ctx.sequelize.getQueryInterface() const queryInterface = ctx.sequelize.getQueryInterface()
const libraryItemsIndexes = await queryInterface.showIndex('libraryItems')
const feedTableDescription = await queryInterface.describeTable('feeds') const feedTableDescription = await queryInterface.describeTable('feeds')
const authorsTableDescription = await queryInterface.describeTable('authors') const authorsTableDescription = await queryInterface.describeTable('authors')
const bookAuthorsTableDescription = await queryInterface.describeTable('bookAuthors') const bookAuthorsTableDescription = await queryInterface.describeTable('bookAuthors')
if (feedTableDescription?.coverPath && authorsTableDescription?.lastFirst && bookAuthorsTableDescription?.createdAt && libraryItemsIndexes.some(lii => lii.name === 'library_items_created_at')) { if (feedTableDescription?.coverPath && authorsTableDescription?.lastFirst && bookAuthorsTableDescription?.createdAt) {
Logger.info(`[dbMigration] Migration patch 2.3.3+ - columns already on model`) Logger.info(`[dbMigration] Migration patch 2.3.3+ - columns already on model`)
return false return false
} }
@ -1633,20 +1632,7 @@ module.exports.migrationPatch2 = async (ctx) => {
try { try {
await queryInterface.sequelize.transaction(t => { await queryInterface.sequelize.transaction(t => {
const queries = [ const queries = []
queryInterface.addIndex('libraryItems', {
fields: ['mediaId'],
transaction: t
}),
queryInterface.addIndex('libraryItems', {
fields: ['createdAt'],
transaction: t
}),
queryInterface.addIndex('mediaProgresses', {
fields: ['updatedAt'],
transaction: t
})
]
if (!bookAuthorsTableDescription?.createdAt) { if (!bookAuthorsTableDescription?.createdAt) {
queries.push(...[ queries.push(...[
queryInterface.addColumn('bookAuthors', 'createdAt', { queryInterface.addColumn('bookAuthors', 'createdAt', {