chore: build
This commit is contained in:
@@ -19,12 +19,19 @@ type Product struct {
|
||||
func (Product) TableName() string { return "products" }
|
||||
|
||||
type ProductPrice struct {
|
||||
ID int `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
ProductID int `json:"product_id" gorm:"column:product_id;index"`
|
||||
Quantity float64 `json:"quantity" gorm:"column:quantity" binding:"required"`
|
||||
Price float64 `json:"price" gorm:"column:price" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
ActivePrice bool `json:"active_price" gorm:"column:active_price;default:true"`
|
||||
ID int `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
ProductID int `json:"product_id" gorm:"column:product_id;index"`
|
||||
Quantity float64 `json:"quantity" gorm:"column:quantity" binding:"required"`
|
||||
Price float64 `json:"price" gorm:"column:price" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
// Pas de tag gorm "default:true" ici : GORM omet de l'INSERT tout champ
|
||||
// dont la valeur Go est la valeur zéro (false) s'il porte un tag
|
||||
// "default", laissant Postgres appliquer sa propre valeur par défaut
|
||||
// (TRUE) à la place — un prix explicitement désactivé (false) revenait
|
||||
// donc toujours actif après un Create(). La colonne a déjà son défaut
|
||||
// TRUE posé au niveau SQL (db_init.go), ce tag Go était redondant et
|
||||
// seulement source du bug.
|
||||
ActivePrice bool `json:"active_price" gorm:"column:active_price"`
|
||||
}
|
||||
|
||||
func (ProductPrice) TableName() string { return "product_prices" }
|
||||
|
||||
Reference in New Issue
Block a user