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

namespace Workflow.Infrastructure.Persistence.Configurations;

public class FormDefinitionFieldConfiguration : IEntityTypeConfiguration<FormDefinitionField>
{
    public void Configure(EntityTypeBuilder<FormDefinitionField> builder)
    {
        builder.ToTable("wf_form_definition_fields");

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

        builder.Property(e => e.FieldKey).HasMaxLength(500);
        builder.Property(e => e.Label).HasMaxLength(500);
        builder.Property(e => e.DefaultValue).HasMaxLength(500);
        builder.Property(e => e.Config).HasColumnType("jsonb");

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