feat: render local artist images with no foreign key
This commit is contained in:
@@ -37,6 +37,8 @@ func (db *DB) Migrate(ctx MigrationContext) error {
|
||||
construct(ctx, "202102191448", migratePodcastAutoDownload),
|
||||
construct(ctx, "202110041330", migrateAlbumCreatedAt),
|
||||
construct(ctx, "202111021951", migrateAlbumRootDir),
|
||||
construct(ctx, "202201042236", migrateArtistGuessedFolder),
|
||||
construct(ctx, "202202092013", migrateArtistCover),
|
||||
}
|
||||
|
||||
return gormigrate.
|
||||
@@ -306,3 +308,28 @@ func migrateAlbumRootDir(tx *gorm.DB, ctx MigrationContext) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func migrateArtistGuessedFolder(tx *gorm.DB, ctx MigrationContext) error {
|
||||
return tx.AutoMigrate(Artist{}).Error
|
||||
}
|
||||
|
||||
func migrateArtistCover(tx *gorm.DB, ctx MigrationContext) error {
|
||||
step := tx.AutoMigrate(
|
||||
Artist{},
|
||||
)
|
||||
if err := step.Error; err != nil {
|
||||
return fmt.Errorf("step auto migrate: %w", err)
|
||||
}
|
||||
|
||||
if !tx.Dialect().HasColumn("artists", "guessed_folder_id") {
|
||||
return nil
|
||||
}
|
||||
|
||||
step = tx.Exec(`
|
||||
ALTER TABLE artists DROP COLUMN guessed_folder_id
|
||||
`)
|
||||
if err := step.Error; err != nil {
|
||||
return fmt.Errorf("step drop column: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ type Artist struct {
|
||||
NameUDec string `sql:"default: null"`
|
||||
Albums []*Album `gorm:"foreignkey:TagArtistID"`
|
||||
AlbumCount int `sql:"-"`
|
||||
Cover string `sql:"default: null"`
|
||||
}
|
||||
|
||||
func (a *Artist) SID() *specid.ID {
|
||||
|
||||
Reference in New Issue
Block a user