You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
742 B

  1. // Copyright 2019 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. package migrations
  5. import (
  6. "xorm.io/xorm"
  7. )
  8. func removeLabelUneededCols(x *xorm.Engine) error {
  9. // Make sure the columns exist before dropping them
  10. type Label struct {
  11. QueryString string
  12. IsSelected bool
  13. }
  14. if err := x.Sync2(new(Label)); err != nil {
  15. return err
  16. }
  17. sess := x.NewSession()
  18. defer sess.Close()
  19. if err := sess.Begin(); err != nil {
  20. return err
  21. }
  22. if err := dropTableColumns(sess, "label", "query_string"); err != nil {
  23. return err
  24. }
  25. if err := dropTableColumns(sess, "label", "is_selected"); err != nil {
  26. return err
  27. }
  28. return sess.Commit()
  29. }