code.gitea.io/gitea@v1.21.7/models/migrations/v1_13/v154.go (about)

     1  // Copyright 2020 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package v1_13 //nolint
     5  
     6  import (
     7  	"code.gitea.io/gitea/modules/timeutil"
     8  
     9  	"xorm.io/xorm"
    10  )
    11  
    12  func AddTimeStamps(x *xorm.Engine) error {
    13  	// this will add timestamps where it is useful to have
    14  
    15  	// Star represents a starred repo by an user.
    16  	type Star struct {
    17  		CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
    18  	}
    19  	if err := x.Sync(new(Star)); err != nil {
    20  		return err
    21  	}
    22  
    23  	// Label represents a label of repository for issues.
    24  	type Label struct {
    25  		CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
    26  		UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
    27  	}
    28  	if err := x.Sync(new(Label)); err != nil {
    29  		return err
    30  	}
    31  
    32  	// Follow represents relations of user and their followers.
    33  	type Follow struct {
    34  		CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
    35  	}
    36  	if err := x.Sync(new(Follow)); err != nil {
    37  		return err
    38  	}
    39  
    40  	// Watch is connection request for receiving repository notification.
    41  	type Watch struct {
    42  		CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
    43  		UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
    44  	}
    45  	if err := x.Sync(new(Watch)); err != nil {
    46  		return err
    47  	}
    48  
    49  	// Collaboration represent the relation between an individual and a repository.
    50  	type Collaboration struct {
    51  		CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
    52  		UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
    53  	}
    54  	return x.Sync(new(Collaboration))
    55  }