mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 00:54:43 +01:00 
			
		
		
		
	Backport #34456 by @lunny Fix #34455 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		
							parent
							
								
									d6233c25b5
								
							
						
					
					
						commit
						d2cbe2fba0
					
				| @ -14,5 +14,8 @@ func AddIndexToActionTaskStoppedLogExpired(x *xorm.Engine) error { | |||||||
| 		Stopped    timeutil.TimeStamp `xorm:"index(stopped_log_expired)"` | 		Stopped    timeutil.TimeStamp `xorm:"index(stopped_log_expired)"` | ||||||
| 		LogExpired bool               `xorm:"index(stopped_log_expired)"` | 		LogExpired bool               `xorm:"index(stopped_log_expired)"` | ||||||
| 	} | 	} | ||||||
| 	return x.Sync(new(ActionTask)) | 	_, err := x.SyncWithOptions(xorm.SyncOptions{ | ||||||
|  | 		IgnoreDropIndices: true, | ||||||
|  | 	}, new(ActionTask)) | ||||||
|  | 	return err | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										51
									
								
								models/migrations/v1_23/v302_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								models/migrations/v1_23/v302_test.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,51 @@ | |||||||
|  | // Copyright 2025 The Gitea Authors. All rights reserved. | ||||||
|  | // SPDX-License-Identifier: MIT | ||||||
|  | 
 | ||||||
|  | package v1_23 //nolint | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"testing" | ||||||
|  | 
 | ||||||
|  | 	"code.gitea.io/gitea/models/migrations/base" | ||||||
|  | 	"code.gitea.io/gitea/modules/timeutil" | ||||||
|  | 
 | ||||||
|  | 	"github.com/stretchr/testify/assert" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | func Test_AddIndexToActionTaskStoppedLogExpired(t *testing.T) { | ||||||
|  | 	type ActionTask struct { | ||||||
|  | 		ID       int64 | ||||||
|  | 		JobID    int64 | ||||||
|  | 		Attempt  int64 | ||||||
|  | 		RunnerID int64              `xorm:"index"` | ||||||
|  | 		Status   int                `xorm:"index"` | ||||||
|  | 		Started  timeutil.TimeStamp `xorm:"index"` | ||||||
|  | 		Stopped  timeutil.TimeStamp `xorm:"index(stopped_log_expired)"` | ||||||
|  | 
 | ||||||
|  | 		RepoID            int64  `xorm:"index"` | ||||||
|  | 		OwnerID           int64  `xorm:"index"` | ||||||
|  | 		CommitSHA         string `xorm:"index"` | ||||||
|  | 		IsForkPullRequest bool | ||||||
|  | 
 | ||||||
|  | 		Token          string `xorm:"-"` | ||||||
|  | 		TokenHash      string `xorm:"UNIQUE"` // sha256 of token | ||||||
|  | 		TokenSalt      string | ||||||
|  | 		TokenLastEight string `xorm:"index token_last_eight"` | ||||||
|  | 
 | ||||||
|  | 		LogFilename  string  // file name of log | ||||||
|  | 		LogInStorage bool    // read log from database or from storage | ||||||
|  | 		LogLength    int64   // lines count | ||||||
|  | 		LogSize      int64   // blob size | ||||||
|  | 		LogIndexes   []int64 `xorm:"LONGBLOB"`                   // line number to offset | ||||||
|  | 		LogExpired   bool    `xorm:"index(stopped_log_expired)"` // files that are too old will be deleted | ||||||
|  | 
 | ||||||
|  | 		Created timeutil.TimeStamp `xorm:"created"` | ||||||
|  | 		Updated timeutil.TimeStamp `xorm:"updated index"` | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// Prepare and load the testing database | ||||||
|  | 	x, deferable := base.PrepareTestEnv(t, 0, new(ActionTask)) | ||||||
|  | 	defer deferable() | ||||||
|  | 
 | ||||||
|  | 	assert.NoError(t, AddIndexToActionTaskStoppedLogExpired(x)) | ||||||
|  | } | ||||||
| @ -9,5 +9,8 @@ func AddIndexForReleaseSha1(x *xorm.Engine) error { | |||||||
| 	type Release struct { | 	type Release struct { | ||||||
| 		Sha1 string `xorm:"INDEX VARCHAR(64)"` | 		Sha1 string `xorm:"INDEX VARCHAR(64)"` | ||||||
| 	} | 	} | ||||||
| 	return x.Sync(new(Release)) | 	_, err := x.SyncWithOptions(xorm.SyncOptions{ | ||||||
|  | 		IgnoreDropIndices: true, | ||||||
|  | 	}, new(Release)) | ||||||
|  | 	return err | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										40
									
								
								models/migrations/v1_23/v304_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								models/migrations/v1_23/v304_test.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | |||||||
|  | // Copyright 2025 The Gitea Authors. All rights reserved. | ||||||
|  | // SPDX-License-Identifier: MIT | ||||||
|  | 
 | ||||||
|  | package v1_23 //nolint | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"testing" | ||||||
|  | 
 | ||||||
|  | 	"code.gitea.io/gitea/models/migrations/base" | ||||||
|  | 	"code.gitea.io/gitea/modules/timeutil" | ||||||
|  | 
 | ||||||
|  | 	"github.com/stretchr/testify/assert" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | func Test_AddIndexForReleaseSha1(t *testing.T) { | ||||||
|  | 	type Release struct { | ||||||
|  | 		ID               int64  `xorm:"pk autoincr"` | ||||||
|  | 		RepoID           int64  `xorm:"INDEX UNIQUE(n)"` | ||||||
|  | 		PublisherID      int64  `xorm:"INDEX"` | ||||||
|  | 		TagName          string `xorm:"INDEX UNIQUE(n)"` | ||||||
|  | 		OriginalAuthor   string | ||||||
|  | 		OriginalAuthorID int64 `xorm:"index"` | ||||||
|  | 		LowerTagName     string | ||||||
|  | 		Target           string | ||||||
|  | 		Title            string | ||||||
|  | 		Sha1             string `xorm:"VARCHAR(64)"` | ||||||
|  | 		NumCommits       int64 | ||||||
|  | 		Note             string             `xorm:"TEXT"` | ||||||
|  | 		IsDraft          bool               `xorm:"NOT NULL DEFAULT false"` | ||||||
|  | 		IsPrerelease     bool               `xorm:"NOT NULL DEFAULT false"` | ||||||
|  | 		IsTag            bool               `xorm:"NOT NULL DEFAULT false"` // will be true only if the record is a tag and has no related releases | ||||||
|  | 		CreatedUnix      timeutil.TimeStamp `xorm:"INDEX"` | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// Prepare and load the testing database | ||||||
|  | 	x, deferable := base.PrepareTestEnv(t, 0, new(Release)) | ||||||
|  | 	defer deferable() | ||||||
|  | 
 | ||||||
|  | 	assert.NoError(t, AddIndexForReleaseSha1(x)) | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user