buildr/modules/state/schema/plugin.go
Peter 5af8ddceab
Some checks failed
continuous-integration/drone/push Build is failing
refactor: rework plugins to track their state
- introduce individual commands to manage plugins
- store plugin in state to skip loading them to memory every time
2023-06-29 20:14:52 +02:00

50 lines
911 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"
)
// 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)),
}
}