// Copyright 2025 The Gogs Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package migrations import ( "gorm.io/gorm" ) func createGPGKeysTable(db *gorm.DB) error { type gpgKey struct { ID int64 `gorm:"primaryKey"` OwnerID int64 `gorm:"index;not null"` KeyID string `gorm:"type:VARCHAR(16);unique;not null"` Fingerprint string `gorm:"type:VARCHAR(40);not null"` Content string `gorm:"type:TEXT;not null"` CanSign bool `gorm:"not null;default:false"` CanEncrypt bool `gorm:"not null;default:false"` Emails string `gorm:"type:TEXT"` // JSON array of email addresses CreatedUnix int64 UpdatedUnix int64 ExpiredUnix int64 } if db.Migrator().HasTable(&gpgKey{}) { return errMigrationSkipped } return db.AutoMigrate(&gpgKey{}) }