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.

50 lines
1.4 KiB

  1. // Copyright 2017 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. "time"
  7. "github.com/go-xorm/xorm"
  8. )
  9. func changeGPGKeysColumns(x *xorm.Engine) error {
  10. // EmailAddress is the list of all email addresses of a user. Can contain the
  11. // primary email address, but is not obligatory.
  12. type EmailAddress struct {
  13. ID int64 `xorm:"pk autoincr"`
  14. UID int64 `xorm:"INDEX NOT NULL"`
  15. Email string `xorm:"UNIQUE NOT NULL"`
  16. IsActivated bool
  17. IsPrimary bool `xorm:"-"`
  18. }
  19. // GPGKey represents a GPG key.
  20. type GPGKey struct {
  21. ID int64 `xorm:"pk autoincr"`
  22. OwnerID int64 `xorm:"INDEX NOT NULL"`
  23. KeyID string `xorm:"INDEX CHAR(16) NOT NULL"`
  24. PrimaryKeyID string `xorm:"CHAR(16)"`
  25. Content string `xorm:"TEXT NOT NULL"`
  26. Created time.Time `xorm:"-"`
  27. CreatedUnix int64
  28. Expired time.Time `xorm:"-"`
  29. ExpiredUnix int64
  30. Added time.Time `xorm:"-"`
  31. AddedUnix int64
  32. SubsKey []*GPGKey `xorm:"-"`
  33. Emails []*EmailAddress
  34. CanSign bool
  35. CanEncryptComms bool
  36. CanEncryptStorage bool
  37. CanCertify bool
  38. }
  39. if err := x.DropTables(new(GPGKey)); err != nil {
  40. return err
  41. }
  42. return x.Sync(new(GPGKey))
  43. }