mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-07-24 18:38:42 +00:00
Upgrade Forgejo to our forked [xorm v1.4.0](https://code.forgejo.org/xorm/xorm/compare/v1.3.9-forgejo.12...v1.4.0), which is now named `code.forgejo.org/xorm/xorm` to reflect the current expectation that it is a permanent fork. A small number of API changes were made recently in https://code.forgejo.org/xorm/xorm/issues/120 which are accounted for in this PR, in addition to the module rename. ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. All work and communication must conform to Forgejo's [AI Agreement](https://codeberg.org/forgejo/governance/src/branch/main/AIAgreement.md). 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). ### 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 - [ ] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change. - [x] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12639 Reviewed-by: Otto <otto@codeberg.org>
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v1_21
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"code.forgejo.org/xorm/xorm"
|
|
)
|
|
|
|
// AddGitSizeAndLFSSizeToRepositoryTable: add GitSize and LFSSize columns to Repository
|
|
func AddGitSizeAndLFSSizeToRepositoryTable(x *xorm.Engine) error {
|
|
type Repository struct {
|
|
GitSize int64 `xorm:"NOT NULL DEFAULT 0"`
|
|
LFSSize int64 `xorm:"NOT NULL DEFAULT 0"`
|
|
}
|
|
|
|
sess := x.NewSession()
|
|
defer sess.Close()
|
|
|
|
if err := sess.Begin(); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := sess.Sync(new(Repository)); err != nil {
|
|
return fmt.Errorf("Sync: %w", err)
|
|
}
|
|
|
|
_, err := sess.Exec(`UPDATE repository SET lfs_size=(SELECT SUM(size) FROM lfs_meta_object WHERE lfs_meta_object.repository_id=repository.ID) WHERE EXISTS (SELECT 1 FROM lfs_meta_object WHERE lfs_meta_object.repository_id=repository.ID)`)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, err = sess.Exec(`UPDATE repository SET size = 0 WHERE size IS NULL`)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, err = sess.Exec(`UPDATE repository SET git_size = size - lfs_size WHERE size > lfs_size`)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return sess.Commit()
|
|
}
|