mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-22 04:59:45 +02:00
Merge remote-tracking branch 'upstream/main' into limit-repo-size
This commit is contained in:
@@ -129,7 +129,7 @@ func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error) {
|
||||
}
|
||||
|
||||
func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, error) {
|
||||
if run.Event == webhook_module.HookEventPullRequest {
|
||||
if run.Event == webhook_module.HookEventPullRequest || run.Event == webhook_module.HookEventPullRequestSync {
|
||||
var payload api.PullRequestPayload
|
||||
if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -98,12 +98,10 @@ func (a *Action) TableIndices() []*schemas.Index {
|
||||
actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
|
||||
actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
|
||||
|
||||
indices := []*schemas.Index{actUserIndex, repoIndex}
|
||||
if setting.Database.Type.IsPostgreSQL() {
|
||||
cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType)
|
||||
cudIndex.AddColumn("created_unix", "user_id", "is_deleted")
|
||||
indices = append(indices, cudIndex)
|
||||
}
|
||||
cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType)
|
||||
cudIndex.AddColumn("created_unix", "user_id", "is_deleted")
|
||||
|
||||
indices := []*schemas.Index{actUserIndex, repoIndex, cudIndex}
|
||||
|
||||
return indices
|
||||
}
|
||||
|
||||
@@ -475,8 +475,10 @@ var migrations = []Migration{
|
||||
NewMigration("Fix incorrect project type", v1_20.FixIncorrectProjectType),
|
||||
// v248 -> v249
|
||||
NewMigration("Add version column to action_runner table", v1_20.AddVersionToActionRunner),
|
||||
// v249 -> v250
|
||||
NewMigration("Improve Action table indices v3", v1_20.ImproveActionTableIndices),
|
||||
// to modify later
|
||||
NewMigration("add size limit on repository", v1_20.AddSizeLimitOnRepo),
|
||||
NewMigration("Add size limit on repository", v1_20.AddSizeLimitOnRepo),
|
||||
}
|
||||
|
||||
// GetCurrentDBVersion returns the current db version
|
||||
|
||||
@@ -4,22 +4,9 @@
|
||||
package v1_17 //nolint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func CreateForeignReferenceTable(x *xorm.Engine) error {
|
||||
type ForeignReference struct {
|
||||
// RepoID is the first column in all indices. now we only need 2 indices: (repo, local) and (repo, foreign, type)
|
||||
RepoID int64 `xorm:"UNIQUE(repo_foreign_type) INDEX(repo_local)" `
|
||||
LocalIndex int64 `xorm:"INDEX(repo_local)"` // the resource key inside Gitea, it can be IssueIndex, or some model ID.
|
||||
ForeignIndex string `xorm:"INDEX UNIQUE(repo_foreign_type)"`
|
||||
Type string `xorm:"VARCHAR(16) INDEX UNIQUE(repo_foreign_type)"`
|
||||
}
|
||||
|
||||
if err := x.Sync2(new(ForeignReference)); err != nil {
|
||||
return fmt.Errorf("Sync2: %w", err)
|
||||
}
|
||||
return nil
|
||||
func CreateForeignReferenceTable(_ *xorm.Engine) error {
|
||||
return nil // This table was dropped in v1_19/v237.go
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_20 //nolint
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
type Action struct {
|
||||
UserID int64 // Receiver user id.
|
||||
ActUserID int64 // Action user id.
|
||||
RepoID int64
|
||||
IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
|
||||
IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
|
||||
CreatedUnix timeutil.TimeStamp `xorm:"created"`
|
||||
}
|
||||
|
||||
// TableName sets the name of this table
|
||||
func (a *Action) TableName() string {
|
||||
return "action"
|
||||
}
|
||||
|
||||
// TableIndices implements xorm's TableIndices interface
|
||||
func (a *Action) TableIndices() []*schemas.Index {
|
||||
repoIndex := schemas.NewIndex("r_u_d", schemas.IndexType)
|
||||
repoIndex.AddColumn("repo_id", "user_id", "is_deleted")
|
||||
|
||||
actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
|
||||
actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
|
||||
|
||||
cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType)
|
||||
cudIndex.AddColumn("created_unix", "user_id", "is_deleted")
|
||||
|
||||
indices := []*schemas.Index{actUserIndex, repoIndex, cudIndex}
|
||||
|
||||
return indices
|
||||
}
|
||||
|
||||
func ImproveActionTableIndices(x *xorm.Engine) error {
|
||||
return x.Sync(new(Action))
|
||||
}
|
||||
Reference in New Issue
Block a user