veza/veza-backend-api/internal/models/track_lyrics.go
senke 6b80089706 feat(tracks): add lyrics model and endpoints (E3)
- Migration 084: track_lyrics table
- TrackLyrics model, GetLyrics, CreateOrUpdateLyrics in TrackService
- GET /tracks/:id/lyrics, PUT /tracks/:id/lyrics (owner only)
- Frontend: TrackLyricsSection with show/hide toggle, Lyrics tab
- trackService: getLyrics, updateLyrics
- MSW: handlers for lyrics
2026-02-20 15:36:28 +01:00

33 lines
971 B
Go

package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
// TrackLyrics stores lyrics content for a track (E3)
type TrackLyrics struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id" db:"id"`
TrackID uuid.UUID `gorm:"type:uuid;not null;uniqueIndex" json:"track_id" db:"track_id"`
Content string `gorm:"type:text;not null" json:"content" db:"content"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at" db:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" db:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" db:"deleted_at"`
Track Track `gorm:"foreignKey:TrackID;constraint:OnDelete:CASCADE" json:"-"`
}
// TableName defines the table name for GORM
func (TrackLyrics) TableName() string {
return "track_lyrics"
}
// BeforeCreate hook for UUID
func (m *TrackLyrics) BeforeCreate(tx *gorm.DB) error {
if m.ID == uuid.Nil {
m.ID = uuid.New()
}
return nil
}