diff options
| author | Cody Robibero <cody@robibe.ro> | 2021-12-23 19:38:10 -0700 |
|---|---|---|
| committer | Cody Robibero <cody@robibe.ro> | 2021-12-23 19:38:10 -0700 |
| commit | a04ab6b87637fe378759aaf2b7fa71726150b2b1 (patch) | |
| tree | 62f4e5bdb272e9312bab469cbcda1e13591e7834 /Jellyfin.Server.Implementations/ModelConfiguration/UserConfiguration.cs | |
| parent | c52a2f2f7b130d73a96cdac00f1e63531a04139b (diff) | |
| parent | 8c7dd0a691d150ac4fa5719853554ff569abf1bb (diff) | |
Merge branch 'master' into studios-images-plugin
# Conflicts:
# MediaBrowser.Providers/MediaBrowser.Providers.csproj
Diffstat (limited to 'Jellyfin.Server.Implementations/ModelConfiguration/UserConfiguration.cs')
| -rw-r--r-- | Jellyfin.Server.Implementations/ModelConfiguration/UserConfiguration.cs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Jellyfin.Server.Implementations/ModelConfiguration/UserConfiguration.cs b/Jellyfin.Server.Implementations/ModelConfiguration/UserConfiguration.cs new file mode 100644 index 000000000..a369cf656 --- /dev/null +++ b/Jellyfin.Server.Implementations/ModelConfiguration/UserConfiguration.cs @@ -0,0 +1,56 @@ +using Jellyfin.Data.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Jellyfin.Server.Implementations.ModelConfiguration +{ + /// <summary> + /// FluentAPI configuration for the User entity. + /// </summary> + public class UserConfiguration : IEntityTypeConfiguration<User> + { + /// <inheritdoc/> + public void Configure(EntityTypeBuilder<User> builder) + { + builder + .Property(user => user.Username) + .UseCollation("NOCASE"); + + builder + .HasOne(u => u.ProfileImage) + .WithOne() + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasMany(u => u.Permissions) + .WithOne() + .HasForeignKey(p => p.UserId) + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasMany(u => u.Preferences) + .WithOne() + .HasForeignKey(p => p.UserId) + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasMany(u => u.AccessSchedules) + .WithOne() + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasMany(u => u.DisplayPreferences) + .WithOne() + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasMany(u => u.ItemDisplayPreferences) + .WithOne() + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasIndex(entity => entity.Username) + .IsUnique(); + } + } +} |
