diff --git a/pkg/models/file.go b/pkg/models/file.go index fa0b44b..7078cbc 100644 --- a/pkg/models/file.go +++ b/pkg/models/file.go @@ -21,6 +21,6 @@ type File struct { ParentID sql.NullString `gorm:"type:uuid;index"` Parts datatypes.JSONSlice[api.Part] `gorm:"type:jsonb"` ChannelID *int64 `gorm:"type:bigint"` - CreatedAt time.Time `gorm:"autoCreateTime:false"` + CreatedAt time.Time `gorm:"default:timezone('utc'::text, now())"` UpdatedAt time.Time `gorm:"autoUpdateTime:false"` } diff --git a/pkg/services/file.go b/pkg/services/file.go index e042d26..437de2e 100644 --- a/pkg/services/file.go +++ b/pkg/services/file.go @@ -229,10 +229,8 @@ func (a *apiService) FilesCopy(ctx context.Context, req *api.FileCopy, params ap dbFile.Category = string(file.Category) if req.UpdatedAt.IsSet() && !req.UpdatedAt.Value.IsZero() { dbFile.UpdatedAt = req.UpdatedAt.Value - dbFile.CreatedAt = req.UpdatedAt.Value } else { dbFile.UpdatedAt = time.Now().UTC() - dbFile.CreatedAt = time.Now().UTC() } if err := a.db.Create(&dbFile).Error; err != nil { @@ -316,10 +314,8 @@ func (a *apiService) FilesCreate(ctx context.Context, fileIn *api.File) (*api.Fi fileDB.Encrypted = fileIn.Encrypted.Value if fileIn.UpdatedAt.IsSet() && !fileIn.UpdatedAt.Value.IsZero() { fileDB.UpdatedAt = fileIn.UpdatedAt.Value - fileDB.CreatedAt = fileIn.UpdatedAt.Value } else { fileDB.UpdatedAt = time.Now().UTC() - fileDB.CreatedAt = time.Now().UTC() } if err := a.db.Create(&fileDB).Error; err != nil { if database.IsKeyConflictErr(err) {