52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
"entgo.io/ent/schema/index"
|
|
)
|
|
|
|
// UserTexture holds the schema definition for the UserTexture entity.
|
|
type UserTexture struct {
|
|
ent.Schema
|
|
}
|
|
|
|
// Fields of the UserTexture.
|
|
func (UserTexture) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Int("user_profile_id"),
|
|
field.Int("texture_id"),
|
|
// 皮肤 or 披风
|
|
field.String("type").SchemaType(map[string]string{
|
|
dialect.MySQL: "VARCHAR(10)",
|
|
}),
|
|
// slim or 空
|
|
field.String("variant").SchemaType(map[string]string{
|
|
dialect.MySQL: "VARCHAR(10)",
|
|
}),
|
|
}
|
|
}
|
|
|
|
// Edges of the UserTexture.
|
|
func (UserTexture) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.To("user_profile", UserProfile.Type).
|
|
Unique().
|
|
Required().
|
|
Field("user_profile_id"),
|
|
edge.To("texture", Texture.Type).
|
|
Unique().
|
|
Required().
|
|
Field("texture_id"),
|
|
}
|
|
}
|
|
|
|
func (UserTexture) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Edges("user_profile"),
|
|
index.Edges("texture"),
|
|
}
|
|
}
|