2019-12-28 02:00:58 +05:30
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2022-11-02 14:24:36 +05:30
|
|
|
package v1_11 //nolint
|
2019-12-28 02:00:58 +05:30
|
|
|
|
|
|
|
import (
|
|
|
|
"xorm.io/xorm"
|
|
|
|
)
|
|
|
|
|
2022-11-02 14:24:36 +05:30
|
|
|
func ExtendTrackedTimes(x *xorm.Engine) error {
|
2020-06-10 02:04:05 +05:30
|
|
|
type TrackedTime struct {
|
|
|
|
Time int64 `xorm:"NOT NULL"`
|
|
|
|
Deleted bool `xorm:"NOT NULL DEFAULT false"`
|
|
|
|
}
|
|
|
|
|
2019-12-28 02:00:58 +05:30
|
|
|
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-10 02:04:05 +05:30
|
|
|
if err := sess.Sync2(new(TrackedTime)); err != nil {
|
2019-12-28 02:00:58 +05:30
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return sess.Commit()
|
|
|
|
}
|