41 lines
852 B
Go
41 lines
852 B
Go
package schema
|
|
|
|
import (
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/schema"
|
|
"entgo.io/ent/schema/field"
|
|
"entgo.io/ent/schema/index"
|
|
)
|
|
|
|
// ShopPlayers holds the schema definition for the ShopPlayers entity.
|
|
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("shop_id"),
|
|
field.Int64("player_id"),
|
|
field.Bool("is_primary").Optional().Default(false),
|
|
field.Time("joined_at").Default(time.Now).Immutable(),
|
|
field.Time("left_at").Optional().Nillable(),
|
|
}
|
|
}
|
|
|
|
// Indexes of the ShopPlayers.
|
|
func (ShopPlayers) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Fields("player_id"),
|
|
index.Fields("shop_id", "joined_at"),
|
|
}
|
|
}
|