mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
Fixes #9846. The number of open action runs on a repo is not precomputed and stored on the repo, but is computed as needed and cached. The computation is faster than the update because it only calculates the smaller set of which action runs are not completed (as opposed to counting all of them). ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [x] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [x] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9927 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net> Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package forgejo_migrations
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"xorm.io/xorm"
|
|
"xorm.io/xorm/schemas"
|
|
)
|
|
|
|
func init() {
|
|
registerMigration(&Migration{
|
|
Description: "remove from table repository fields num_action_runs, num_closed_action_runs",
|
|
Upgrade: removeRepositoryActionRunStatFields,
|
|
})
|
|
}
|
|
|
|
func removeRepositoryActionRunStatFields(x *xorm.Engine) error {
|
|
switch x.Dialect().URI().DBType {
|
|
case schemas.SQLITE:
|
|
// Can't drop multiple columns in one statement in SQLite.
|
|
_, err := x.Exec("ALTER TABLE `repository` DROP COLUMN num_action_runs")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = x.Exec("ALTER TABLE `repository` DROP COLUMN num_closed_action_runs")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
case schemas.MYSQL, schemas.POSTGRES:
|
|
_, err := x.Exec("ALTER TABLE `repository` DROP COLUMN num_action_runs, DROP COLUMN num_closed_action_runs")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
default:
|
|
return fmt.Errorf("unsupported db dialect type %v", x.Dialect().URI().DBType)
|
|
}
|
|
return nil
|
|
}
|