v23.go 883 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2025 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. "gorm.io/gorm"
  7. )
  8. func createGPGKeysTable(db *gorm.DB) error {
  9. type gpgKey struct {
  10. ID int64 `gorm:"primaryKey"`
  11. OwnerID int64 `gorm:"index;not null"`
  12. KeyID string `gorm:"type:VARCHAR(16);unique;not null"`
  13. Fingerprint string `gorm:"type:VARCHAR(40);not null"`
  14. Content string `gorm:"type:TEXT;not null"`
  15. CanSign bool `gorm:"not null;default:false"`
  16. CanEncrypt bool `gorm:"not null;default:false"`
  17. Emails string `gorm:"type:TEXT"` // JSON array of email addresses
  18. CreatedUnix int64
  19. UpdatedUnix int64
  20. ExpiredUnix int64
  21. }
  22. if db.Migrator().HasTable(&gpgKey{}) {
  23. return errMigrationSkipped
  24. }
  25. return db.AutoMigrate(&gpgKey{})
  26. }