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.

v187.go 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2021 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 dropWebhookColumns(x *xorm.Engine) error {
  9. // Make sure the columns exist before dropping them
  10. type Webhook struct {
  11. Signature string `xorm:"TEXT"`
  12. IsSSL bool `xorm:"is_ssl"`
  13. }
  14. if err := x.Sync2(new(Webhook)); err != nil {
  15. return err
  16. }
  17. type HookTask struct {
  18. Typ string `xorm:"VARCHAR(16) index"`
  19. URL string `xorm:"TEXT"`
  20. Signature string `xorm:"TEXT"`
  21. HTTPMethod string `xorm:"http_method"`
  22. ContentType int
  23. IsSSL bool
  24. }
  25. if err := x.Sync2(new(HookTask)); err != nil {
  26. return err
  27. }
  28. sess := x.NewSession()
  29. defer sess.Close()
  30. if err := sess.Begin(); err != nil {
  31. return err
  32. }
  33. if err := dropTableColumns(sess, "webhook", "signature", "is_ssl"); err != nil {
  34. return err
  35. }
  36. if err := dropTableColumns(sess, "hook_task", "typ", "url", "signature", "http_method", "content_type", "is_ssl"); err != nil {
  37. return err
  38. }
  39. return sess.Commit()
  40. }