diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-08-22 23:33:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-22 23:33:05 +0800 |
commit | b55c699c62406cb0a98c11e2a3ced99ff12faa41 (patch) | |
tree | f83a07470d86d69a8aa007676b82f3608e00ea6d /models/migrations/v191.go | |
parent | 7f856109420ddce421dab8d37e2590c9a4db4fd0 (diff) | |
download | gitea-b55c699c62406cb0a98c11e2a3ced99ff12faa41.tar.gz gitea-b55c699c62406cb0a98c11e2a3ced99ff12faa41.zip |
Alter issue/comment table TEXT fields to LONGTEXT (#16765)
* Alter issue/comment table TEXT fields to LONGTEXT
* Use If not Switch
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/migrations/v191.go')
-rw-r--r-- | models/migrations/v191.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/models/migrations/v191.go b/models/migrations/v191.go new file mode 100644 index 0000000000..10dfad4f04 --- /dev/null +++ b/models/migrations/v191.go @@ -0,0 +1,29 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package migrations + +import ( + "code.gitea.io/gitea/modules/setting" + "xorm.io/xorm" +) + +func alterIssueAndCommentTextFieldsToLongText(x *xorm.Engine) error { + + sess := x.NewSession() + defer sess.Close() + if err := sess.Begin(); err != nil { + return err + } + + if setting.Database.UseMySQL { + if _, err := sess.Exec("ALTER TABLE `issue` CHANGE `content` `content` LONGTEXT"); err != nil { + return err + } + if _, err := sess.Exec("ALTER TABLE `comment` CHANGE `content` `content` LONGTEXT, CHANGE `patch` `patch` LONGTEXT"); err != nil { + return err + } + } + return sess.Commit() +} |