重构creatingUniqueIndex和createGinIndexes

This commit is contained in:
2025-11-20 17:46:01 +08:00
parent da934a9bbb
commit 1313140e45
2 changed files with 156 additions and 122 deletions

View File

@@ -12,6 +12,10 @@ type PigHouse struct {
Pens []Pen `gorm:"foreignKey:HouseID"` // 一个猪舍包含多个猪栏
}
func (ph PigHouse) TableName() string {
return "pig_houses"
}
// PenStatus 定义了猪栏的当前状态
type PenStatus string
@@ -33,3 +37,7 @@ type Pen struct {
Capacity int `gorm:"not null;comment:设计容量 (头)"`
Status PenStatus `gorm:"not null;index;comment:猪栏当前状态"`
}
func (p Pen) TableName() string {
return "pens"
}