Merge branch 'master'
This commit is contained in:
No files matched your search
@@ -224,6 +224,7 @@ type Track struct {
|
||||
TagDiscNumber int `sql:"default: null"`
|
||||
TagBrainzID string `sql:"default: null"`
|
||||
TagLyrics string `sql:"default: null"`
|
||||
TagYear int `sql:"default: null"`
|
||||
|
||||
ReplayGainTrackGain float32
|
||||
ReplayGainTrackPeak float32
|
||||
|
||||
@@ -83,6 +83,7 @@ func (db *DB) Migrate(ctx MigrationContext) error {
|
||||
construct(ctx, "202509301448", migrateAddTrackEmbeddedCover),
|
||||
construct(ctx, "202512021147", migrateAlbumAddIndexOnCreatedAt),
|
||||
construct(ctx, "202601201000", migrateAddAlbumDiscTitles),
|
||||
construct(ctx, "202602061800", migrateAddTrackYear),
|
||||
}
|
||||
|
||||
return gormigrate.
|
||||
@@ -879,3 +880,22 @@ func migrateAlbumAddIndexOnCreatedAt(tx *gorm.DB, _ MigrationContext) error {
|
||||
func migrateAddAlbumDiscTitles(tx *gorm.DB, _ MigrationContext) error {
|
||||
return tx.AutoMigrate(AlbumDiscTitle{}).Error
|
||||
}
|
||||
|
||||
func migrateAddTrackYear(tx *gorm.DB, _ MigrationContext) error {
|
||||
step := tx.AutoMigrate(Track{})
|
||||
if err := step.Error; err != nil {
|
||||
return fmt.Errorf("step auto migrate: %w", err)
|
||||
}
|
||||
|
||||
step = tx.Exec(`
|
||||
UPDATE tracks
|
||||
SET tag_year=(SELECT tag_year
|
||||
FROM albums
|
||||
WHERE tracks.album_id = albums.id)
|
||||
`)
|
||||
if err := step.Error; err != nil {
|
||||
return fmt.Errorf("step set default track year based on album's : %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user