Peter
5af8ddceab
Some checks failed
continuous-integration/drone/push Build is failing
- introduce individual commands to manage plugins - store plugin in state to skip loading them to memory every time
50 lines
911 B
Go
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)),
|
|
}
|
|
}
|