Skip to content

Commit 62104b4

Browse files
authored
Alter hook_task TEXT fields to LONGTEXT (#20038)
Mysql TEXT has a limit of 64KB, change this to LONGTEXT in mysql only so we can have bigger hook payloads. Postgresql has unlimited TEXT - https://www.postgresql.org/docs/current/datatype-character.html Sqlite has unlimited TEXT - https://www.sqlitetutorial.net/sqlite-data-types/#:~:text=The%20maximum%20length%20of%20TEXT,SQLite%20supports%20various%20character%20encodings. Same issue as #16656 but for hook_task Fixes #10252, #19679, #3561
1 parent 62cb3c8 commit 62104b4

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ var migrations = []Migration{
389389
NewMigration("allow to view files in PRs", addReviewViewedFiles),
390390
// v216 -> v217
391391
NewMigration("Improve Action table indices", improveActionTableIndices),
392+
// v217 -> v218
393+
NewMigration("Alter hook_task table TEXT fields to LONGTEXT", alterHookTaskTextFieldsToLongText),
392394
}
393395

394396
// GetCurrentDBVersion returns the current db version

models/migrations/v217.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"code.gitea.io/gitea/modules/setting"
9+
10+
"xorm.io/xorm"
11+
)
12+
13+
func alterHookTaskTextFieldsToLongText(x *xorm.Engine) error {
14+
sess := x.NewSession()
15+
defer sess.Close()
16+
if err := sess.Begin(); err != nil {
17+
return err
18+
}
19+
20+
if setting.Database.UseMySQL {
21+
if _, err := sess.Exec("ALTER TABLE `hook_task` CHANGE `payload_content` `payload_content` LONGTEXT, CHANGE `request_content` `request_content` LONGTEXT, change `response_content` `response_content` LONGTEXT"); err != nil {
22+
return err
23+
}
24+
}
25+
return sess.Commit()
26+
}

models/webhook/hooktask.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ type HookTask struct {
105105
HookID int64
106106
UUID string
107107
api.Payloader `xorm:"-"`
108-
PayloadContent string `xorm:"TEXT"`
108+
PayloadContent string `xorm:"LONGTEXT"`
109109
EventType HookEventType
110110
IsDelivered bool
111111
Delivered int64
112112
DeliveredString string `xorm:"-"`
113113

114114
// History info.
115115
IsSucceed bool
116-
RequestContent string `xorm:"TEXT"`
116+
RequestContent string `xorm:"LONGTEXT"`
117117
RequestInfo *HookRequest `xorm:"-"`
118-
ResponseContent string `xorm:"TEXT"`
118+
ResponseContent string `xorm:"LONGTEXT"`
119119
ResponseInfo *HookResponse `xorm:"-"`
120120
}
121121

0 commit comments

Comments
 (0)