package schema import ( "entgo.io/ent" "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" "github.com/google/uuid" ) // Plugin holds the schema definition for the Plugin entity. type Plugin struct { ent.Schema } // Fields of the Plugin. func (Plugin) Fields() []ent.Field { return []ent.Field{ field.UUID("id", uuid.UUID{}). Default(uuid.New). Unique(), field.String("name"). Unique(). Immutable(). MaxLen(150), field.String("url"), field.String("local_path"). Unique(), field.Bytes("hash"). Unique(). MaxLen(256), } } func (Plugin) Indexes() []ent.Index { return []ent.Index{ index.Fields("name"). Unique(), } } // Edges of the Plugin. func (Plugin) Edges() []ent.Edge { return []ent.Edge{ edge.To("plugin_modules", PluginModule.Type). Annotations(entsql.OnDelete(entsql.Cascade)), } }