package schema

import (
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
)

// OrderStateLogs holds the schema definition for the OrderStateLogs entity.
type OrderStateLogs struct {
	ent.Schema
}

// Annotations of the OrderStateLogs.
func (OrderStateLogs) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.Annotation{
			Table: "order_state_logs",
		},
	}
}

// Fields of the OrderStateLogs.
func (OrderStateLogs) Fields() []ent.Field {
	return []ent.Field{
		field.Int64("id").Immutable().Unique(),
		field.Int64("order_id"),
		field.String("from_status").Optional().Nillable().MaxLen(30),
		field.String("to_status").MaxLen(30),
		field.String("action").MaxLen(50),
		field.Int64("actor_id"),
		field.String("actor_role").MaxLen(20),
		field.JSON("metadata", map[string]any{}).
			Optional().
			SchemaType(map[string]string{dialect.Postgres: "jsonb"}),
		field.Time("created_at").Default(time.Now).Immutable(),
	}
}

// Edges of the OrderStateLogs.
func (OrderStateLogs) Edges() []ent.Edge {
	return nil
}
