- Add MinIO S3-compatible storage to docker-compose (dev, staging, prod) - Create migrations 103-108 (waveform_url, user_folders, user_files, user_storage_quotas, gear_items.is_public, gear_images) - Add Go models: UserFile, UserFolder, StorageQuota, GearImage - Add WaveformURL to Track model, IsPublic + GearImages to GearItem model
29 lines
685 B
Go
29 lines
685 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type GearImage struct {
|
|
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
|
|
GearID uuid.UUID `gorm:"type:uuid;not null" json:"gear_id"`
|
|
ImageURL string `gorm:"size:500;not null" json:"image_url"`
|
|
Position int `gorm:"not null;default:0" json:"position"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
|
|
GearItem GearItem `gorm:"foreignKey:GearID;constraint:OnDelete:CASCADE" json:"-"`
|
|
}
|
|
|
|
func (GearImage) TableName() string {
|
|
return "gear_images"
|
|
}
|
|
|
|
func (m *GearImage) BeforeCreate(tx *gorm.DB) error {
|
|
if m.ID == uuid.Nil {
|
|
m.ID = uuid.New()
|
|
}
|
|
return nil
|
|
}
|