Skip to content

Commit

Permalink
fix(db): add double index for right side of unique compound indexes
Browse files Browse the repository at this point in the history
fixes #426
  • Loading branch information
sentriz committed Dec 11, 2023
1 parent a8333b8 commit d640a9f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions db/migrations.go
Expand Up @@ -71,6 +71,7 @@ func (db *DB) Migrate(ctx MigrationContext) error {
construct(ctx, "202311062259", migrateArtistAppearances),
construct(ctx, "202311072309", migrateAlbumInfo),
construct(ctx, "202311082304", migrateTemporaryDisplayAlbumArtist),
construct(ctx, "202312110003", migrateAddExtraIndexes),
}

return gormigrate.
Expand Down Expand Up @@ -802,3 +803,13 @@ func migrateTemporaryDisplayAlbumArtist(tx *gorm.DB, _ MigrationContext) error {
WHERE tag_album_artist=''
`).Error
}

func migrateAddExtraIndexes(tx *gorm.DB, _ MigrationContext) error {
return tx.Exec(`
CREATE INDEX idx_track_genres_genre_id ON "track_genres" (genre_id);
CREATE INDEX idx_album_genres_genre_id ON "album_genres" (genre_id);
CREATE INDEX idx_album_artists_artist_id ON "album_artists" (artist_id);
CREATE INDEX idx_track_artists_artist_id ON "track_artists" (artist_id);
CREATE INDEX idx_artist_appearances_album_id ON "artist_appearances" (album_id);
`).Error
}

0 comments on commit d640a9f

Please sign in to comment.