fix: shop_players 关系表主键与模型对齐

This commit is contained in:
zetaloop
2026-04-04 06:25:49 +08:00
parent 3a81aec527
commit 7dc088eadf
18 changed files with 91 additions and 310 deletions
@@ -4,6 +4,7 @@ import (
"time"
"entgo.io/ent"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
@@ -13,10 +14,15 @@ type ShopPlayers struct {
ent.Schema
}
func (ShopPlayers) Annotations() []schema.Annotation {
return []schema.Annotation{
field.ID("shop_id", "player_id"),
}
}
// Fields of the ShopPlayers.
func (ShopPlayers) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").Immutable().Unique(),
field.Int64("shop_id"),
field.Int64("player_id"),
field.Bool("is_primary").Optional().Default(false),
@@ -28,13 +34,7 @@ func (ShopPlayers) Fields() []ent.Field {
// Indexes of the ShopPlayers.
func (ShopPlayers) Indexes() []ent.Index {
return []ent.Index{
index.Fields("shop_id", "player_id").Unique(),
index.Fields("player_id"),
index.Fields("shop_id", "joined_at"),
}
}
// Edges of the ShopPlayers.
func (ShopPlayers) Edges() []ent.Edge {
return nil
}