TinySkin/db/ent/schema/usertexture.go
thehrz 145bb045e9
Some checks failed
CI / deploy (push) Failing after 2m53s
fork from xmdhs/authlib-skin
2025-01-24 16:57:58 +08:00

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"),
// skin or cape
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"),
}
}