diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-11-03 08:28:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-03 15:28:46 +0800 |
commit | f8f859b8fa1d365c3d2b2f741dce82effa9c03f0 (patch) | |
tree | 502d494c635ed20982245fff3980206620b70bf8 | |
parent | 81ea4f95a0a82506ccc350ead38ec7d290fad3cc (diff) | |
download | gitea-f8f859b8fa1d365c3d2b2f741dce82effa9c03f0.tar.gz gitea-f8f859b8fa1d365c3d2b2f741dce82effa9c03f0.zip |
Alter package_version.metadata_json to LONGTEXT (#21667)
-rw-r--r-- | models/migrations/migrations.go | 2 | ||||
-rw-r--r-- | models/migrations/v1_19/v232.go | 26 | ||||
-rw-r--r-- | models/packages/package_version.go | 2 |
3 files changed, 29 insertions, 1 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 9291473f0d..f7f48bee02 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -433,6 +433,8 @@ var migrations = []Migration{ NewMigration("Add ConfidentialClient column (default true) to OAuth2Application table", v1_18.AddConfidentialClientColumnToOAuth2ApplicationTable), // v231 -> v232 NewMigration("Add index for hook_task", v1_19.AddIndexForHookTask), + // v232 -> v233 + NewMigration("Alter package_version.metadata_json to LONGTEXT", v1_19.AlterPackageVersionMetadataToLongText), } // GetCurrentDBVersion returns the current db version diff --git a/models/migrations/v1_19/v232.go b/models/migrations/v1_19/v232.go new file mode 100644 index 0000000000..92c9ad84b7 --- /dev/null +++ b/models/migrations/v1_19/v232.go @@ -0,0 +1,26 @@ +// Copyright 2022 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 v1_19 // nolint + +import ( + "code.gitea.io/gitea/modules/setting" + + "xorm.io/xorm" +) + +func AlterPackageVersionMetadataToLongText(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 `package_version` MODIFY COLUMN `metadata_json` LONGTEXT"); err != nil { + return err + } + } + return sess.Commit() +} diff --git a/models/packages/package_version.go b/models/packages/package_version.go index f9965bcb74..782261c575 100644 --- a/models/packages/package_version.go +++ b/models/packages/package_version.go @@ -33,7 +33,7 @@ type PackageVersion struct { LowerVersion string `xorm:"UNIQUE(s) INDEX NOT NULL"` CreatedUnix timeutil.TimeStamp `xorm:"created INDEX NOT NULL"` IsInternal bool `xorm:"INDEX NOT NULL DEFAULT false"` - MetadataJSON string `xorm:"metadata_json TEXT"` + MetadataJSON string `xorm:"metadata_json LONGTEXT"` DownloadCount int64 `xorm:"NOT NULL DEFAULT 0"` } |