TinySkin/db/ent/schema/texture.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

38 lines
783 B
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"
)
// Texture holds the schema definition for the Texture entity.
type Texture struct {
ent.Schema
}
// Fields of the Texture.
func (Texture) Fields() []ent.Field {
return []ent.Field{
field.String("texture_hash").SchemaType(map[string]string{
dialect.MySQL: "VARCHAR(100)",
}),
}
}
// Edges of the Texture.
func (Texture) Edges() []ent.Edge {
return []ent.Edge{
edge.To("created_user", User.Type).Unique().Required(),
edge.To("user_profile", UserProfile.Type).Through("usertexture", UserTexture.Type),
}
}
func (Texture) Indexes() []ent.Index {
return []ent.Index{
index.Fields("texture_hash").Unique(),
}
}