mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-11-07 08:34:10 +01:00
Update index creation migration to be idempotent
This commit is contained in:
parent
84012d9090
commit
35e2681ea9
@ -19,15 +19,25 @@ async function up({ context: { queryInterface, logger } }) {
|
|||||||
|
|
||||||
// Create index for bookAuthors
|
// Create index for bookAuthors
|
||||||
logger.info('[2.15.2 migration] Creating index for bookAuthors')
|
logger.info('[2.15.2 migration] Creating index for bookAuthors')
|
||||||
await queryInterface.addIndex('bookAuthors', ['authorId'], {
|
const bookAuthorsIndexes = await queryInterface.showIndex('bookAuthors')
|
||||||
name: 'bookAuthor_authorId'
|
if (!bookAuthorsIndexes.some((index) => index.name === 'bookAuthor_authorId')) {
|
||||||
})
|
await queryInterface.addIndex('bookAuthors', ['authorId'], {
|
||||||
|
name: 'bookAuthor_authorId'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
logger.info('[2.15.2 migration] Index bookAuthor_authorId already exists')
|
||||||
|
}
|
||||||
|
|
||||||
// Create index for bookSeries
|
// Create index for bookSeries
|
||||||
logger.info('[2.15.2 migration] Creating index for bookSeries')
|
logger.info('[2.15.2 migration] Creating index for bookSeries')
|
||||||
await queryInterface.addIndex('bookSeries', ['seriesId'], {
|
const bookSeriesIndexes = await queryInterface.showIndex('bookSeries')
|
||||||
name: 'bookSeries_seriesId'
|
if (!bookSeriesIndexes.some((index) => index.name === 'bookSeries_seriesId')) {
|
||||||
})
|
await queryInterface.addIndex('bookSeries', ['seriesId'], {
|
||||||
|
name: 'bookSeries_seriesId'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
logger.info('[2.15.2 migration] Index bookSeries_seriesId already exists')
|
||||||
|
}
|
||||||
|
|
||||||
// Delete existing podcastEpisode index
|
// Delete existing podcastEpisode index
|
||||||
logger.info('[2.15.2 migration] Deleting existing podcastEpisode index')
|
logger.info('[2.15.2 migration] Deleting existing podcastEpisode index')
|
||||||
@ -35,9 +45,14 @@ async function up({ context: { queryInterface, logger } }) {
|
|||||||
|
|
||||||
// Create index for podcastEpisode and createdAt
|
// Create index for podcastEpisode and createdAt
|
||||||
logger.info('[2.15.2 migration] Creating index for podcastEpisode and createdAt')
|
logger.info('[2.15.2 migration] Creating index for podcastEpisode and createdAt')
|
||||||
await queryInterface.addIndex('podcastEpisodes', ['createdAt', 'podcastId'], {
|
const podcastEpisodesIndexes = await queryInterface.showIndex('podcastEpisodes')
|
||||||
name: 'podcastEpisode_createdAt_podcastId'
|
if (!podcastEpisodesIndexes.some((index) => index.name === 'podcastEpisode_createdAt_podcastId')) {
|
||||||
})
|
await queryInterface.addIndex('podcastEpisodes', ['createdAt', 'podcastId'], {
|
||||||
|
name: 'podcastEpisode_createdAt_podcastId'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
logger.info('[2.15.2 migration] Index podcastEpisode_createdAt_podcastId already exists')
|
||||||
|
}
|
||||||
|
|
||||||
// Completed migration
|
// Completed migration
|
||||||
logger.info('[2.15.2 migration] UPGRADE END: 2.15.2-index-creation')
|
logger.info('[2.15.2 migration] UPGRADE END: 2.15.2-index-creation')
|
||||||
|
Loading…
Reference in New Issue
Block a user