2019-12-28 04:30:58 +08:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2022-11-28 02:20:29 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
2019-12-28 04:30:58 +08:00
|
|
|
|
2022-11-02 16:54:36 +08:00
|
|
|
package v1_11 //nolint
|
2019-12-28 04:30:58 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"xorm.io/xorm"
|
|
|
|
)
|
|
|
|
|
2022-11-02 16:54:36 +08:00
|
|
|
func ExtendTrackedTimes(x *xorm.Engine) error {
|
2020-06-10 04:34:05 +08:00
|
|
|
type TrackedTime struct {
|
|
|
|
Time int64 `xorm:"NOT NULL"`
|
|
|
|
Deleted bool `xorm:"NOT NULL DEFAULT false"`
|
|
|
|
}
|
|
|
|
|
2019-12-28 04:30:58 +08: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
|
|
|
|
}
|
|
|
|
|
2023-08-14 03:17:21 +08:00
|
|
|
if err := sess.Sync(new(TrackedTime)); err != nil {
|
2019-12-28 04:30:58 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return sess.Commit()
|
|
|
|
}
|