You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
670 B

  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "xorm.io/xorm"
  7. )
  8. func extendTrackedTimes(x *xorm.Engine) error {
  9. type TrackedTime struct {
  10. Time int64 `xorm:"NOT NULL"`
  11. Deleted bool `xorm:"NOT NULL DEFAULT false"`
  12. }
  13. sess := x.NewSession()
  14. defer sess.Close()
  15. if err := sess.Begin(); err != nil {
  16. return err
  17. }
  18. if _, err := sess.Exec("DELETE FROM tracked_time WHERE time IS NULL"); err != nil {
  19. return err
  20. }
  21. if err := sess.Sync2(new(TrackedTime)); err != nil {
  22. return err
  23. }
  24. return sess.Commit()
  25. }