using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace GeoRitmMover.GeoRitm.Data.EntityConfigurations;
public class SourceAlertEntityConfiguration : IEntityTypeConfiguration<SourceAlert>
{
	public void Configure(EntityTypeBuilder<SourceAlert> builder)
	{
		_ = builder.ToTable("object_alerts");

		_ = builder.HasKey(x => x.Id);
		_ = builder.Property(x => x.Id)
			.HasColumnName("id")
			.IsRequired();

		_ = builder.Property(x => x.ObjectId)
			.HasColumnName("object_id")
			.IsRequired();

		_ = builder.Property(x => x.ReceivedAt)
			.HasColumnName("recived_at");

		_ = builder.Property(x => x.AlertAt)
			.HasColumnName("alert_ts");

		_ = builder.Property(x => x.IsAlarm)
			.HasColumnName("is_alarm")
			.IsRequired();

		_ = builder.Property(x => x.MessageId)
			.HasColumnName("alert_message_id");

		_ = builder.HasOne(x => x.Message)
			.WithMany()
			.HasForeignKey(x => x.MessageId);

		_ = builder.Property(x => x.Area)
			.HasColumnName("area");

		_ = builder.Property(x => x.Zone)
			.HasColumnName("area_zone");

		_ = builder.Property(x => x.CloseComment)
			.HasColumnName("close_comment");

		_ = builder.Property(x => x.Info)
			.HasColumnName("info");
	}
}
