1
Fork 0

Fix Postgres exif flash migration error message

Closes #648
This commit is contained in:
viktorstrate 2022-02-13 16:57:20 +01:00
parent 0b9d04eff2
commit e9a4839f48
No known key found for this signature in database
GPG Key ID: 3F855605109C1E8A
1 changed files with 9 additions and 0 deletions

View File

@ -118,6 +118,15 @@ func migrate_exif_fields_flash(db *gorm.DB) error {
err := db.Transaction(func(tx *gorm.DB) error {
var data_type string
if err := tx.Raw("SELECT data_type FROM information_schema.columns WHERE table_name = 'media_exif' AND column_name = 'flash';").Find(&data_type).Error; err != nil {
return errors.Wrapf(err, "read data_type of column media_exif.flash")
}
if data_type == "bigint" {
return nil
}
if err := tx.Exec("UPDATE media_exif SET flash = NULL WHERE flash = ''").Error; err != nil {
return errors.Wrapf(err, "convert flash attribute empty values to NULL")
}