using Asentrafin.Api.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Asentrafin.Api.Data.Configurations; public class PlaidAccountConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("plaid_accounts"); builder.HasKey(account => account.Id); builder.Property(account => account.PlaidAccountId).HasMaxLength(128).IsRequired(); builder.Property(account => account.Name).HasMaxLength(256).IsRequired(); builder.Property(account => account.OfficialName).HasMaxLength(512); builder.Property(account => account.Mask).HasMaxLength(32); builder.Property(account => account.Type).HasMaxLength(64).IsRequired(); builder.Property(account => account.Subtype).HasMaxLength(64); builder.Property(account => account.IsoCurrencyCode).HasMaxLength(8); builder.Property(account => account.UnofficialCurrencyCode).HasMaxLength(32); builder.Property(account => account.RawJson).HasColumnType("jsonb"); builder.HasIndex(account => account.PlaidAccountId).IsUnique(); builder.HasOne(account => account.PlaidItem) .WithMany(item => item.Accounts) .HasForeignKey(account => account.PlaidItemId) .OnDelete(DeleteBehavior.Cascade); } }