using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Workflow.Domain.Entities;

namespace Workflow.Infrastructure.Persistence.Configurations;

public class WorkflowTaskConfiguration : IEntityTypeConfiguration<WorkflowTask>
{
    public void Configure(EntityTypeBuilder<WorkflowTask> builder)
    {
        builder.ToTable("wf_workflow_tasks");

        builder.HasKey(e => e.Id);
        builder.Property(e => e.Id).ValueGeneratedNever();

        builder.Property(e => e.NodeId).HasMaxLength(500);
        builder.Property(e => e.Title).HasMaxLength(500);
        builder.Property(e => e.AssigneeId).HasMaxLength(500);
        builder.Property(e => e.AssigneeRole).HasMaxLength(500);
        builder.Property(e => e.CandidateUsers).HasMaxLength(500);
        builder.Property(e => e.CandidateRoles).HasMaxLength(500);
        builder.Property(e => e.Result).HasColumnType("jsonb");
        builder.Property(e => e.Comment).HasMaxLength(2000);
        builder.Property(e => e.OperatorIP).HasMaxLength(500);

        builder.HasIndex(e => e.InstanceId);
    }
}
