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" ) // PluginModule holds the schema definition for the PluginModule entity. type PluginModule struct { ent.Schema } // Fields of the PluginModule. func (PluginModule) Fields() []ent.Field { return []ent.Field{ field.UUID("id", uuid.UUID{}). Default(uuid.New). Unique(), field.String("type"). MinLen(1), field.Int("category"). Min(1), field.Bytes("default_spec"). NotEmpty(), } } func (PluginModule) Indexes() []ent.Index { return []ent.Index{ index.Fields("type", "category").Unique(), } } // Edges of the PluginModule. func (PluginModule) Edges() []ent.Edge { return []ent.Edge{ edge.From("plugin", Plugin.Type). Ref("plugin_modules"). Unique(). Annotations(entsql.OnDelete(entsql.Cascade)), } }