Browse Source

restore: reset milestone deadline_unix and closed_date_unix (#5264)

pull/5319/head
Unknwon 7 years ago
parent
commit
2a86b3e31d
No known key found for this signature in database
GPG Key ID: 7A02C406FAC875A2
  1. 2
      gogs.go
  2. 16
      models/models.go
  3. 2
      templates/.VERSION

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogs/gogs/pkg/setting"
)
const APP_VER = "0.11.59.0626"
const APP_VER = "0.11.59.0627"
func init() {
setting.AppVer = APP_VER

16
models/models.go

@ -360,16 +360,24 @@ func ImportDatabase(dirPath string, verbose bool) (err error) {
return fmt.Errorf("insert strcut: %v", err)
}
meta := make(map[string]interface{})
if err = jsoniter.Unmarshal(scanner.Bytes(), &meta); err != nil {
log.Error(2, "Failed to unmarshal to map: %v", err)
}
// Reset created_unix back to the date save in archive because Insert method updates its value
if isInsertProcessor && !skipInsertProcessors[rawTableName] {
meta := make(map[string]interface{})
if err = jsoniter.Unmarshal(scanner.Bytes(), &meta); err != nil {
log.Error(2, "Failed to unmarshal to map: %v", err)
}
if _, err = x.Exec("UPDATE "+rawTableName+" SET created_unix=? WHERE id=?", meta["CreatedUnix"], meta["ID"]); err != nil {
log.Error(2, "Failed to reset 'created_unix': %v", err)
}
}
switch rawTableName {
case "milestone":
if _, err = x.Exec("UPDATE "+rawTableName+" SET deadline_unix=?, closed_date_unix=? WHERE id=?", meta["DeadlineUnix"], meta["ClosedDateUnix"], meta["ID"]); err != nil {
log.Error(2, "Failed to reset 'milestone.deadline_unix', 'milestone.closed_date_unix': %v", err)
}
}
}
// PostgreSQL needs manually reset table sequence for auto increment keys

2
templates/.VERSION

@ -1 +1 @@
0.11.59.0626
0.11.59.0627

Loading…
Cancel
Save