2019-12-27 20:30:58 +00:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2022-11-27 18:20:29 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2019-12-27 20:30:58 +00:00
|
|
|
|
2022-11-02 08:54:36 +00:00
|
|
|
package v1_11 //nolint
|
2019-12-27 20:30:58 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"xorm.io/xorm"
|
|
|
|
)
|
|
|
|
|
2022-11-02 08:54:36 +00:00
|
|
|
func ExtendTrackedTimes(x *xorm.Engine) error {
|
2020-06-09 20:34:05 +00:00
|
|
|
type TrackedTime struct {
|
|
|
|
Time int64 `xorm:"NOT NULL"`
|
|
|
|
Deleted bool `xorm:"NOT NULL DEFAULT false"`
|
|
|
|
}
|
|
|
|
|
2019-12-27 20:30:58 +00:00
|
|
|
sess := x.NewSession()
|
|
|
|
defer sess.Close()
|
|
|
|
|
|
|
|
if err := sess.Begin(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := sess.Exec("DELETE FROM tracked_time WHERE time IS NULL"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-06-09 20:34:05 +00:00
|
|
|
if err := sess.Sync2(new(TrackedTime)); err != nil {
|
2019-12-27 20:30:58 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return sess.Commit()
|
|
|
|
}
|