[BE-DB-004] be-db: Add created_at and updated_at timestamps to all models
This commit is contained in:
parent
012dca8da0
commit
b646243bdf
8 changed files with 12 additions and 3 deletions
|
|
@ -3035,7 +3035,7 @@
|
|||
"description": "Ensure all models have proper timestamp tracking",
|
||||
"owner": "backend",
|
||||
"estimated_hours": 4,
|
||||
"status": "todo",
|
||||
"status": "completed",
|
||||
"files_involved": [],
|
||||
"implementation_steps": [
|
||||
{
|
||||
|
|
@ -3056,7 +3056,9 @@
|
|||
"Unit tests",
|
||||
"Integration tests"
|
||||
],
|
||||
"notes": ""
|
||||
"notes": "",
|
||||
"completed_at": "2025-12-24T15:08:41.886115",
|
||||
"implementation_notes": "Added UpdatedAt timestamp to models missing it: TrackLike, TrackHistory, RefreshToken, PlaylistVersion, HLSTranscodeQueue, BitrateAdaptationLog, PlaybackAnalytics. All models now have proper CreatedAt and UpdatedAt timestamps with GORM autoCreateTime and autoUpdateTime tags. DTOs and constants (track_status.go, custom_claims.go, requests.go, responses.go) do not need timestamps as they are not database models."
|
||||
},
|
||||
{
|
||||
"id": "BE-DB-005",
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ type BitrateAdaptationLog struct {
|
|||
Reason BitrateAdaptationReason `gorm:"type:varchar(50);not null" json:"reason"`
|
||||
NetworkBandwidth *int `gorm:"type:integer" json:"network_bandwidth,omitempty"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;index:idx_bitrate_adaptation_created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName définit le nom de la table pour GORM
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ type HLSTranscodeQueue struct {
|
|||
RetryCount int `gorm:"not null;default:0" json:"retry_count"`
|
||||
MaxRetries int `gorm:"not null;default:3" json:"max_retries"`
|
||||
ErrorMessage *string `gorm:"type:text" json:"error_message,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
StartedAt *time.Time `json:"started_at,omitempty"`
|
||||
CompletedAt *time.Time `json:"completed_at,omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ type PlaybackAnalytics struct {
|
|||
StartedAt time.Time `gorm:"not null" json:"started_at"`
|
||||
EndedAt *time.Time `json:"ended_at,omitempty"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;index:idx_playback_analytics_created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName définit le nom de la table pour GORM
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ type PlaylistVersion struct {
|
|||
// Snapshot des tracks au moment de la version (JSON)
|
||||
TracksSnapshot string `gorm:"type:text" json:"tracks_snapshot,omitempty" db:"tracks_snapshot"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;index:idx_playlist_versions_created_at" json:"created_at" db:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" db:"updated_at"`
|
||||
|
||||
// Relations
|
||||
Playlist *Playlist `gorm:"foreignKey:PlaylistID;constraint:OnDelete:CASCADE" json:"playlist,omitempty"`
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ type RefreshToken struct {
|
|||
TokenHash string `gorm:"not null;size:255;index:idx_refresh_tokens_token_hash" json:"-"`
|
||||
ExpiresAt time.Time `gorm:"not null" json:"expires_at"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
// Relations
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ type TrackHistory struct {
|
|||
OldValue string `gorm:"type:text" json:"old_value,omitempty" db:"old_value"`
|
||||
NewValue string `gorm:"type:text" json:"new_value,omitempty" db:"new_value"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;index:idx_track_history_created_at" json:"created_at" db:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" db:"updated_at"`
|
||||
|
||||
// Relations
|
||||
Track *Track `gorm:"foreignKey:TrackID;constraint:OnDelete:CASCADE" json:"track,omitempty"`
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ type TrackLike struct {
|
|||
UserID uuid.UUID `gorm:"type:uuid;not null;index:idx_track_likes_user;uniqueIndex:idx_track_likes_unique" json:"user_id" db:"user_id"`
|
||||
TrackID uuid.UUID `gorm:"type:uuid;not null;index:idx_track_likes_track;uniqueIndex:idx_track_likes_unique" json:"track_id" db:"track_id"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;default:CURRENT_TIMESTAMP" json:"created_at" db:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" db:"updated_at"`
|
||||
|
||||
// Relations
|
||||
User User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE" json:"-"`
|
||||
|
|
|
|||
Loading…
Reference in a new issue