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

v30.go 953B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2017 The Gogs 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. "fmt"
  7. "github.com/go-xorm/xorm"
  8. )
  9. func addExternalLoginUserPK(x *xorm.Engine) error {
  10. // ExternalLoginUser see models/external_login_user.go
  11. type ExternalLoginUser struct {
  12. ExternalID string `xorm:"pk NOT NULL"`
  13. UserID int64 `xorm:"INDEX NOT NULL"`
  14. LoginSourceID int64 `xorm:"pk NOT NULL"`
  15. }
  16. extlogins := make([]*ExternalLoginUser, 0, 6)
  17. if err := x.Find(&extlogins); err != nil {
  18. return fmt.Errorf("Find: %v", err)
  19. }
  20. if err := x.DropTables(new(ExternalLoginUser)); err != nil {
  21. return fmt.Errorf("DropTables: %v", err)
  22. }
  23. if err := x.Sync2(new(ExternalLoginUser)); err != nil {
  24. return fmt.Errorf("Sync2: %v", err)
  25. }
  26. if _, err := x.Insert(extlogins); err != nil {
  27. return fmt.Errorf("Insert: %v", err)
  28. }
  29. return nil
  30. }