mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Fix: table naming
This commit is contained in:
		
							parent
							
								
									ea6882d9ab
								
							
						
					
					
						commit
						e8a1ea3b54
					
				@ -8,7 +8,7 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This upward migration script adds indexes to speed up queries on the `BookAuthor`, `BookSeries`, and `PodcastEpisode` tables.
 | 
			
		||||
 * This upward migration script adds indexes to speed up queries on the `BookAuthor`, `BookSeries`, and `podcastEpisodes` tables.
 | 
			
		||||
 *
 | 
			
		||||
 * @param {MigrationOptions} options - an object containing the migration context.
 | 
			
		||||
 * @returns {Promise<void>} - A promise that resolves when the migration is complete.
 | 
			
		||||
@ -19,23 +19,23 @@ async function up({ context: { queryInterface, logger } }) {
 | 
			
		||||
 | 
			
		||||
  // Create index for bookAuthors
 | 
			
		||||
  logger.info('[2.15.2 migration] Creating index for bookAuthors')
 | 
			
		||||
  await queryInterface.addIndex('BookAuthor', ['authorId'], {
 | 
			
		||||
  await queryInterface.addIndex('bookAuthors', ['authorId'], {
 | 
			
		||||
    name: 'bookAuthor_authorId'
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  // Create index for bookSeries
 | 
			
		||||
  logger.info('[2.15.2 migration] Creating index for bookSeries')
 | 
			
		||||
  await queryInterface.addIndex('BookSeries', ['seriesId'], {
 | 
			
		||||
  await queryInterface.addIndex('bookSeries', ['seriesId'], {
 | 
			
		||||
    name: 'bookSeries_seriesId'
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  // Delete existing podcastEpisode index
 | 
			
		||||
  logger.info('[2.15.2 migration] Deleting existing podcastEpisode index')
 | 
			
		||||
  await queryInterface.removeIndex('PodcastEpisode', 'podcast_episode_created_at')
 | 
			
		||||
  await queryInterface.removeIndex('podcastEpisodes', 'podcast_episode_created_at')
 | 
			
		||||
 | 
			
		||||
  // Create index for podcastEpisode and createdAt
 | 
			
		||||
  logger.info('[2.15.2 migration] Creating index for podcastEpisode and createdAt')
 | 
			
		||||
  await queryInterface.addIndex('PodcastEpisode', ['createdAt', 'podcastId'], {
 | 
			
		||||
  await queryInterface.addIndex('podcastEpisodes', ['createdAt', 'podcastId'], {
 | 
			
		||||
    name: 'podcastEpisode_createdAt_podcastId'
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
@ -44,7 +44,7 @@ async function up({ context: { queryInterface, logger } }) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This downward migration script removes the newly created indexes and re-adds the old index on the `PodcastEpisode` table.
 | 
			
		||||
 * This downward migration script removes the newly created indexes and re-adds the old index on the `podcastEpisodes` table.
 | 
			
		||||
 *
 | 
			
		||||
 * @param {MigrationOptions} options - an object containing the migration context.
 | 
			
		||||
 * @returns {Promise<void>} - A promise that resolves when the migration is complete.
 | 
			
		||||
@ -55,19 +55,19 @@ async function down({ context: { queryInterface, logger } }) {
 | 
			
		||||
 | 
			
		||||
  // Remove index for bookAuthors
 | 
			
		||||
  logger.info('[2.15.2 migration] Removing index for bookAuthors')
 | 
			
		||||
  await queryInterface.removeIndex('BookAuthor', 'bookAuthor_authorId')
 | 
			
		||||
  await queryInterface.removeIndex('bookAuthors', 'bookAuthor_authorId')
 | 
			
		||||
 | 
			
		||||
  // Remove index for bookSeries
 | 
			
		||||
  logger.info('[2.15.2 migration] Removing index for bookSeries')
 | 
			
		||||
  await queryInterface.removeIndex('BookSeries', 'bookSeries_seriesId')
 | 
			
		||||
  await queryInterface.removeIndex('bookSeries', 'bookSeries_seriesId')
 | 
			
		||||
 | 
			
		||||
  // Delete existing podcastEpisode index
 | 
			
		||||
  logger.info('[2.15.2 migration] Deleting existing podcastEpisode index')
 | 
			
		||||
  await queryInterface.removeIndex('PodcastEpisode', 'podcastEpisode_createdAt_podcastId')
 | 
			
		||||
  await queryInterface.removeIndex('podcastEpisodes', 'podcastEpisode_createdAt_podcastId')
 | 
			
		||||
 | 
			
		||||
  // Create index for podcastEpisode and createdAt
 | 
			
		||||
  logger.info('[2.15.2 migration] Creating index for podcastEpisode createdAt')
 | 
			
		||||
  await queryInterface.addIndex('PodcastEpisode', ['createdAt'], {
 | 
			
		||||
  await queryInterface.addIndex('podcastEpisodes', ['createdAt'], {
 | 
			
		||||
    name: 'podcast_episode_created_at'
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user