mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
New Settings entity
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using Govor.Core.Models.Users;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Govor.Data.Configurations;
|
||||
|
||||
|
||||
public class PrivacyRuleEntityConfiguration : IEntityTypeConfiguration<PrivacyRuleEntity>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PrivacyRuleEntity> builder)
|
||||
{
|
||||
builder.HasKey(r => r.Id);
|
||||
|
||||
builder.Property(r => r.OwnerId).IsRequired();
|
||||
builder.Property(r => r.Area).IsRequired().HasConversion<string>();
|
||||
builder.Property(r => r.AccessType).IsRequired().HasConversion<string>();
|
||||
|
||||
builder.Property(r => r.Whitelist).HasColumnType("jsonb");
|
||||
builder.Property(r => r.Blacklist).HasColumnType("jsonb");
|
||||
|
||||
builder.HasIndex(r => r.OwnerId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Govor.Core.Models.Users;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Govor.Data.Configurations;
|
||||
|
||||
public class PrivacyUserSettingsConfiguration : IEntityTypeConfiguration<PrivacyUserSettings>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PrivacyUserSettings> builder)
|
||||
{
|
||||
// Primary Key
|
||||
builder.HasKey(p => p.UserId);
|
||||
|
||||
builder.Property(p => p.DeletingVia)
|
||||
.IsRequired()
|
||||
.HasConversion<string>()
|
||||
.HasDefaultValue(DeletingMessagesVia.None); // Adjust default as needed
|
||||
|
||||
builder.Property(p => p.DeletingIn)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(0);
|
||||
|
||||
// Relationship Configuration
|
||||
builder.HasMany(p => p.Rules)
|
||||
.WithOne(r => r.OwnerSettings)
|
||||
.HasForeignKey(r => r.OwnerId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user