mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
37 lines
920 B
Go
37 lines
920 B
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v1_21
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hanzoai/git/models/db"
|
|
"github.com/hanzoai/git/modules/timeutil"
|
|
)
|
|
|
|
func AddExpiredUnixColumnInActionArtifactTable(x db.EngineMigration) error {
|
|
type ActionArtifact struct {
|
|
ExpiredUnix timeutil.TimeStamp `xorm:"index"` // time when the artifact will be expired
|
|
}
|
|
if err := x.Sync(new(ActionArtifact)); err != nil {
|
|
return err
|
|
}
|
|
return updateArtifactsExpiredUnixTo90Days(x)
|
|
}
|
|
|
|
func updateArtifactsExpiredUnixTo90Days(x db.EngineMigration) error {
|
|
sess := x.NewSession()
|
|
defer sess.Close()
|
|
|
|
if err := sess.Begin(); err != nil {
|
|
return err
|
|
}
|
|
expiredTime := time.Now().AddDate(0, 0, 90).Unix()
|
|
if _, err := sess.Exec(`UPDATE action_artifact SET expired_unix=? WHERE status='2' AND expired_unix is NULL`, expiredTime); err != nil {
|
|
return err
|
|
}
|
|
|
|
return sess.Commit()
|
|
}
|