gitea源码

v313.go 819B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2025 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_24
  4. import (
  5. "code.gitea.io/gitea/models/migrations/base"
  6. "xorm.io/xorm"
  7. )
  8. func MovePinOrderToTableIssuePin(x *xorm.Engine) error {
  9. type IssuePin struct {
  10. ID int64 `xorm:"pk autoincr"`
  11. RepoID int64 `xorm:"UNIQUE(s) NOT NULL"`
  12. IssueID int64 `xorm:"UNIQUE(s) NOT NULL"`
  13. IsPull bool `xorm:"NOT NULL"`
  14. PinOrder int `xorm:"DEFAULT 0"`
  15. }
  16. if err := x.Sync(new(IssuePin)); err != nil {
  17. return err
  18. }
  19. if _, err := x.Exec("INSERT INTO issue_pin (repo_id, issue_id, is_pull, pin_order) SELECT repo_id, id, is_pull, pin_order FROM issue WHERE pin_order > 0"); err != nil {
  20. return err
  21. }
  22. sess := x.NewSession()
  23. defer sess.Close()
  24. return base.DropTableColumns(sess, "issue", "pin_order")
  25. }