package models import ( "time" "github.com/google/uuid" "gorm.io/gorm" ) // TrackRepost represents a user reposting a track to their profile (v0.10.3 F203). type TrackRepost struct { ID uuid.UUID `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"` UserID uuid.UUID `gorm:"type:uuid;not null;index:idx_track_reposts_user_id" json:"user_id"` TrackID uuid.UUID `gorm:"type:uuid;not null;index:idx_track_reposts_track_id" json:"track_id"` CreatedAt time.Time `gorm:"autoCreateTime;index:idx_track_reposts_created_at" json:"created_at"` User User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE" json:"-"` Track Track `gorm:"foreignKey:TrackID;constraint:OnDelete:CASCADE" json:"-"` } // TableName returns the table name for GORM. func (TrackRepost) TableName() string { return "track_reposts" } // BeforeCreate generates UUID if not set. func (m *TrackRepost) BeforeCreate(tx *gorm.DB) error { if m.ID == uuid.Nil { m.ID = uuid.New() } return nil }