alter primary keys to uuids and adjust the membership system

This commit is contained in:
Fran Jurmanović
2025-06-30 22:50:52 +02:00
parent caba5bae70
commit c17e7742ee
53 changed files with 12641 additions and 805 deletions

View File

@@ -12,12 +12,13 @@ import (
"strings"
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
// SteamCredentials represents stored Steam login credentials
type SteamCredentials struct {
ID uint `gorm:"primaryKey" json:"id"`
ID uuid.UUID `gorm:"type:uuid;primary_key;" json:"id"`
Username string `gorm:"not null" json:"username"`
Password string `gorm:"not null" json:"-"` // Encrypted, not exposed in JSON
DateCreated time.Time `json:"dateCreated"`
@@ -31,6 +32,10 @@ func (SteamCredentials) TableName() string {
// BeforeCreate is a GORM hook that runs before creating new credentials
func (s *SteamCredentials) BeforeCreate(tx *gorm.DB) error {
if s.ID == uuid.Nil {
s.ID = uuid.New()
}
now := time.Now().UTC()
if s.DateCreated.IsZero() {
s.DateCreated = now