feat: мультироль
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 9s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 2m6s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 26s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 6s
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 9s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 2m6s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 26s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 6s
This commit is contained in:
@@ -10,6 +10,7 @@ public class AppDbContext : DbContext
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
||||
|
||||
public DbSet<User> Users { get; set; } = null!;
|
||||
public DbSet<UserRoleAssignment> UserRoles { get; set; } = null!;
|
||||
public DbSet<StudentProfile> StudentProfiles { get; set; } = null!;
|
||||
public DbSet<TeacherProfile> TeacherProfiles { get; set; } = null!;
|
||||
public DbSet<Course> Courses { get; set; } = null!;
|
||||
|
||||
@@ -15,7 +15,6 @@ public class UserConfiguration : IEntityTypeConfiguration<User>
|
||||
builder.Property(u => u.Email).HasColumnName("email").HasMaxLength(255).IsRequired();
|
||||
builder.Property(u => u.DisplayName).HasColumnName("display_name").HasMaxLength(255);
|
||||
builder.Property(u => u.AvatarUrl).HasColumnName("avatar_url").HasMaxLength(500);
|
||||
builder.Property(u => u.Role).HasColumnName("role");
|
||||
builder.Property(u => u.IsActive).HasColumnName("is_active").HasDefaultValue(true);
|
||||
builder.Property(u => u.MicrosoftId).HasColumnName("microsoft_id").HasMaxLength(255);
|
||||
builder.Property(u => u.Xp).HasColumnName("xp").HasDefaultValue(0);
|
||||
@@ -25,5 +24,10 @@ public class UserConfiguration : IEntityTypeConfiguration<User>
|
||||
|
||||
builder.HasIndex(u => u.Email).IsUnique();
|
||||
builder.HasIndex(u => u.MicrosoftId).IsUnique().HasFilter("microsoft_id IS NOT NULL");
|
||||
|
||||
builder.HasMany(u => u.Roles)
|
||||
.WithOne(ur => ur.User)
|
||||
.HasForeignKey(ur => ur.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using UniVerse.Domain.Entities;
|
||||
|
||||
namespace UniVerse.Infrastructure.Data.Configurations;
|
||||
|
||||
public class UserRoleAssignmentConfiguration : IEntityTypeConfiguration<UserRoleAssignment>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserRoleAssignment> builder)
|
||||
{
|
||||
builder.ToTable("user_roles");
|
||||
|
||||
builder.HasKey(ur => new { ur.UserId, ur.Role });
|
||||
builder.Property(ur => ur.UserId).HasColumnName("user_id");
|
||||
builder.Property(ur => ur.Role).HasColumnName("role");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user