feat(db): add an index on albums.created_at

related #620
This commit is contained in:
sentriz
2025-12-02 11:48:27 +01:00
parent 1df6d02e6e
commit 816e437d44
+7
View File
@@ -81,6 +81,7 @@ func (db *DB) Migrate(ctx MigrationContext) error {
construct(ctx, "202508261102", migrateAddLyrics),
construct(ctx, "202509291741", migrateAddAlbumEmbeddedCoverTrackID),
construct(ctx, "202509301448", migrateAddTrackEmbeddedCover),
construct(ctx, "202512021147", migrateAlbumAddIndexOnCreatedAt),
}
return gormigrate.
@@ -867,3 +868,9 @@ func migrateAddAlbumEmbeddedCoverTrackID(tx *gorm.DB, _ MigrationContext) error
func migrateAddTrackEmbeddedCover(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(Track{}).Error
}
func migrateAlbumAddIndexOnCreatedAt(tx *gorm.DB, _ MigrationContext) error {
return tx.Exec(`
CREATE INDEX idx_albums_created_at ON "albums" (created_at);
`).Error
}