summaryrefslogtreecommitdiffstats
path: root/models/migrations/v57.go
blob: fe4bf6b0ee736ef7502c3c130ef0d35165e82aec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2017 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.

package migrations

import (
	"fmt"

	"code.gitea.io/gitea/modules/timeutil"

	"github.com/go-xorm/xorm"
)

func addIssueClosedTime(x *xorm.Engine) error {
	// Issue see models/issue.go
	type Issue struct {
		ClosedUnix timeutil.TimeStamp `xorm:"INDEX"`
	}

	if err := x.Sync2(new(Issue)); err != nil {
		return fmt.Errorf("Sync2: %v", err)
	}

	if _, err := x.Exec("UPDATE `issue` SET `closed_unix` = `updated_unix` WHERE `is_closed` = ?", true); err != nil {
		return err
	}

	return nil
}