mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 22:29:07 +00:00
* Split long functions and optimize code * Replace `errors.Wrap()` with the `fmt.Errorf()`; rename `process*()` functions to `parse*()` --------- Co-authored-by: Konstantin Koval
25 lines
644 B
Go
25 lines
644 B
Go
package migrations
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/photoview/photoview/api/graphql/models"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// MigrateForExifGPSCorrection finds and removes invalid GPS data from media_exif table
|
|
func MigrateForExifGPSCorrection(db *gorm.DB) error {
|
|
return db.Transaction(func(tx *gorm.DB) error {
|
|
if err := tx.Model(&models.MediaEXIF{}).
|
|
Where("ABS(gps_longitude) > ?", 90).
|
|
Or("ABS(gps_latitude) > ?", 90).
|
|
Updates(map[string]interface{}{
|
|
"gps_latitude": nil,
|
|
"gps_longitude": nil,
|
|
}).Error; err != nil {
|
|
return fmt.Errorf("failed to remove invalid GPS data from media_exif table: %w", err)
|
|
}
|
|
return nil
|
|
})
|
|
}
|