aboutsummaryrefslogtreecommitdiff
path: root/models/migrations/v18.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/migrations/v18.go')
-rw-r--r--models/migrations/v18.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/models/migrations/v18.go b/models/migrations/v18.go
new file mode 100644
index 00000000..086cd27a
--- /dev/null
+++ b/models/migrations/v18.go
@@ -0,0 +1,34 @@
+// Copyright 2018 The Gogs 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 (
+ "fmt"
+
+ "github.com/go-xorm/xorm"
+
+ "github.com/gogs/gogs/pkg/setting"
+)
+
+func updateRepositoryDescriptionField(x *xorm.Engine) error {
+ exist, err := x.IsTableExist("repository")
+ if err != nil {
+ return fmt.Errorf("IsTableExist: %v", err)
+ } else if !exist {
+ return nil
+ }
+ switch {
+ case setting.UseMySQL:
+ _, err = x.Exec("ALTER TABLE `repository` MODIFY `description` VARCHAR(512);")
+ case setting.UseMSSQL:
+ _, err = x.Exec("ALTER TABLE `repository` ALTER COLUMN `description` VARCHAR(512);")
+ case setting.UsePostgreSQL:
+ _, err = x.Exec("ALTER TABLE `repository` ALTER COLUMN `description` TYPE VARCHAR(512);")
+ case setting.UseSQLite3:
+ // Sqlite3 uses TEXT type by default for any string type field.
+ // Keep this comment to mention that we don't missed any option.
+ }
+ return err
+}