buildr/modules/state/schema/kventry.go
Peter fee941a0e4
feat(state): introduce SQLite based state store
Allow modules to keep a state of their latest execution and skp if not necessary
2023-05-02 18:44:47 +02:00

47 lines
767 B
Go

package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/google/uuid"
)
// KVEntry holds the schema definition for the KVEntry entity.
type KVEntry struct {
ent.Schema
}
func (KVEntry) Indexes() []ent.Index {
return []ent.Index{
index.Fields("key").
Unique(),
}
}
// Fields of the KVEntry.
func (KVEntry) Fields() []ent.Field {
return []ent.Field{
field.UUID("id", uuid.UUID{}).
Default(uuid.New),
field.Bytes("key").
Unique().
Immutable().
MaxLen(32).
NotEmpty(),
field.Time("modified_at").
Default(time.Now),
field.Time("ttl").
Optional().
Nillable(),
field.Bytes("state"),
}
}
// Edges of the KVEntry.
func (KVEntry) Edges() []ent.Edge {
return nil
}