mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-07-10 16:00:04 +02:00

The models/actions/run.go:GetRunBefore function sorts ActionRun rows to get the most recently stopped. Since the ActionRun rows do not expire, the cost will keep increasing over time. The index is meant to ensure the execution time of the associated query does not grow linearly with the number of rows in the ActionRun table. Ref https://codeberg.org/forgejo/forgejo/pulls/7491/files#issuecomment-5495441 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8252 Reviewed-by: Christopher Besch <mail@chris-besch.com> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
19 lines
387 B
Go
19 lines
387 B
Go
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package forgejo_migrations //nolint:revive
|
|
|
|
import (
|
|
"forgejo.org/modules/timeutil"
|
|
|
|
"xorm.io/xorm"
|
|
)
|
|
|
|
func AddIndexToActionRunStopped(x *xorm.Engine) error {
|
|
type ActionRun struct {
|
|
ID int64
|
|
Stopped timeutil.TimeStamp `xorm:"index"`
|
|
}
|
|
|
|
return x.Sync(&ActionRun{})
|
|
}
|