buildr/modules/state/schema/plugin_module.go
Peter e60726ef9e
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
feat: implement new and man for plugin modules
- use extracted shared libraries
2023-08-23 22:06:26 +02:00

47 lines
927 B
Go

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)),
}
}