diff --git a/schema/ent/schema/general_queue.go b/schema/ent/schema/general_queue.go new file mode 100644 index 0000000..2cabbdc --- /dev/null +++ b/schema/ent/schema/general_queue.go @@ -0,0 +1,32 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" +) + +type GeneralQueue struct { + ent.Schema +} + +func (GeneralQueue) Fields() []ent.Field { + return []ent.Field{ + field.String("name"), + field.JSON("payload", map[string]interface{}{}), + field.Enum("status").Values("pending", "in_progress", "completed", "failed"), + field.Int("number_of_tries").Default(0), + field.Int("max_retries").Default(3), + field.String("error_message").Optional(), + field.JSON("failure_payload", map[string]interface{}{}).Optional(), + field.JSON("result_payload", map[string]interface{}{}).Optional(), + field.Time("created_at"), + field.Time("updated_at"), + field.Time("processed_at").Optional(), + } +} + +func (GeneralQueue) Annotations() []schema.Annotation { + return []schema.Annotation{entsql.Annotation{Table: "generalQueue"}} +} diff --git a/schema/ent/schema/general_queue_state.go b/schema/ent/schema/general_queue_state.go new file mode 100644 index 0000000..904621c --- /dev/null +++ b/schema/ent/schema/general_queue_state.go @@ -0,0 +1,36 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" +) + +type GeneralQueueState struct { + ent.Schema +} + +func (GeneralQueueState) Fields() []ent.Field { + return []ent.Field{ + field.String("name"). + Unique(). + Immutable(). + Comment("Name of the queue (e.g., 'email', 'notifications')"), + field.Bool("running"). + Default(false). + Comment("Whether the queue is currently running"), + field.Time("updated_at"). + Comment("Last time the state was updated"), + } +} + +func (GeneralQueueState) Edges() []ent.Edge { + return nil +} + +func (GeneralQueueState) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Annotation{Table: "generalQueueState"}, + } +}