Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

v34.go 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2017 Gitea. 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. package migrations
  5. import (
  6. "fmt"
  7. "code.gitea.io/gitea/modules/log"
  8. "code.gitea.io/gitea/modules/setting"
  9. "github.com/go-xorm/xorm"
  10. )
  11. // ActionV34 describes the removed fields
  12. type ActionV34 struct {
  13. ActUserName string `xorm:"-"`
  14. RepoUserName string `xorm:"-"`
  15. RepoName string `xorm:"-"`
  16. }
  17. // TableName will be invoked by XORM to customize the table name
  18. func (*ActionV34) TableName() string {
  19. return "action"
  20. }
  21. func removeActionColumns(x *xorm.Engine) error {
  22. switch {
  23. case setting.UseSQLite3:
  24. log.Warn("Unable to drop columns in SQLite")
  25. case setting.UseMySQL, setting.UsePostgreSQL, setting.UseMSSQL, setting.UseTiDB:
  26. if _, err := x.Exec("ALTER TABLE action DROP COLUMN act_user_name"); err != nil {
  27. return fmt.Errorf("DROP COLUMN act_user_name: %v", err)
  28. } else if _, err = x.Exec("ALTER TABLE action DROP COLUMN repo_user_name"); err != nil {
  29. return fmt.Errorf("DROP COLUMN repo_user_name: %v", err)
  30. } else if _, err = x.Exec("ALTER TABLE action DROP COLUMN repo_name"); err != nil {
  31. return fmt.Errorf("DROP COLUMN repo_name: %v", err)
  32. }
  33. default:
  34. log.Fatal(4, "Unrecognized DB")
  35. }
  36. return nil
  37. }