package models import ( "time" "github.com/google/uuid" "gorm.io/gorm" ) // CertificateRevocationList represents a Certificate Revocation List (CRL) type CertificateRevocationList struct { ID uuid.UUID `json:"id" gorm:"type:uuid;primary_key;default:gen_random_uuid()"` SerialNumber string `json:"serial_number" gorm:"not null;unique"` CertificateAuthorityID uuid.UUID `json:"certificate_authority_id" gorm:"type:uuid;not null"` Version int `json:"version" gorm:"not null;default:2"` ThisUpdate time.Time `json:"this_update" gorm:"not null"` NextUpdate time.Time `json:"next_update" gorm:"not null"` FilePath string `json:"file_path" gorm:"not null"` // Path to CRL file RevokedCertificates string `json:"revoked_certificates"` // JSON array of revoked certificate serial numbers with reasons CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"` DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` // Relationships CertificateAuthority *CertificateAuthority `json:"certificate_authority" gorm:"foreignKey:CertificateAuthorityID"` } // TableName returns the table name for CertificateRevocationList func (crl *CertificateRevocationList) TableName() string { return "certificate_revocation_lists" } // BeforeCreate generates a new UUID before creating the record func (crl *CertificateRevocationList) BeforeCreate(tx *gorm.DB) (err error) { crl.ID = uuid.New() return }