diff --git a/pkg/models/pools.go b/pkg/models/pools.go index 0b4dad6..466bb46 100644 --- a/pkg/models/pools.go +++ b/pkg/models/pools.go @@ -9,8 +9,10 @@ const ( type Pool struct { BaseModel[PoolID] - Name string `json:"name" gorm:"type:varchar(25)"` - Category PoolCategory `json:"category" gorm:"type:pool_category;type:enum('series', 'collection')"` + Name string `json:"name" gorm:"column:name;type:varchar(25)"` + Category PoolCategory `json:"category" gorm:"column:category;type:pool_category;type:enum('series', 'collection')"` + Posts []PoolPost `json:"posts" gorm:"foreignKey:PoolID"` + Sources []PoolReference `json:"sources" gorm:"foreignKey:PoolID"` } func (Pool) TableName() string { @@ -18,11 +20,10 @@ func (Pool) TableName() string { } type PoolPost struct { - Pool Pool `json:"pool" gorm:"foreignKey:ID;references:PoolID"` - PoolID PoolID `json:"pool_id" gorm:""` - Post Post `json:"post" gorm:"foreignKey:ID;references:PostID"` - PostID PostID `json:"post_id" gorm:""` - OrderPosition int `json:"order_position" gorm:"not null;default:0"` + PoolID PoolID `json:"pool_id" gorm:"column:pool_id;primaryKey"` + Pool Pool `json:"-"` + PostID PostID `json:"post_id" gorm:"column:post_id;primaryKey"` + OrderPosition int `json:"order_position" gorm:"column:order_position;default:0"` } func (PoolPost) TableName() string { @@ -30,11 +31,10 @@ func (PoolPost) TableName() string { } type PoolReference struct { - Pool Pool `json:"pool" gorm:"foreignKey:ID;references:PoolID"` - PoolID PoolID `json:"pool_id" gorm:""` - Source Source `json:"source" gorm:"foreignKey:ID;references:SourceID"` - SourceID SourceID `json:"source_id" gorm:""` - URL string `json:"url" gorm:"not null"` + PoolID PoolID `json:"pool_id" gorm:"column:pool_id;primaryKey"` + Pool Pool `json:"-"` + SourceID SourceID `json:"source_id" gorm:"column:source_id;primaryKey"` + URL string `json:"url" gorm:"column:url;primaryKey"` } func (PoolReference) TableName() string {