mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Implements Authorization system
This commit is contained in:
1 parent
5bfb2ca212
commit
2c9c210e43
68 files changed
+2734
-336
No files matched your search
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Common.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Configures the entity mapping for the <see cref="PermissionEntity"/> entity.
|
||||
/// </summary>
|
||||
public class PermissionConfiguration : IEntityTypeConfiguration<PermissionEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the <see cref="PermissionEntity"/> entity.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder to be used to configure the entity.</param>
|
||||
public void Configure(EntityTypeBuilder<PermissionEntity> builder)
|
||||
{
|
||||
builder.ToTable("Permissions");
|
||||
builder.HasKey(permission => permission.Id);
|
||||
builder.Property(permission => permission.Id)
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(permission => permission.PermissionName)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnOrder(1);
|
||||
|
||||
// audit
|
||||
builder.Property(permission => permission.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(2);
|
||||
|
||||
builder.Property(permission => permission.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
builder.Property(permission => permission.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(4);
|
||||
|
||||
builder.Property(permission => permission.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(5);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Common.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Configures the entity mapping for the <see cref="RoleEntity"/> entity.
|
||||
/// </summary>
|
||||
public class RoleConfiguration : IEntityTypeConfiguration<RoleEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the <see cref="RoleEntity"/> entity.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder to be used to configure the entity.</param>
|
||||
public void Configure(EntityTypeBuilder<RoleEntity> builder)
|
||||
{
|
||||
builder.ToTable("Roles");
|
||||
builder.HasKey(role => role.Id);
|
||||
builder.Property(role => role.Id)
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(role => role.RoleName)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnOrder(1);
|
||||
|
||||
// audit
|
||||
builder.Property(role => role.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(2);
|
||||
|
||||
builder.Property(role => role.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
builder.Property(role => role.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(4);
|
||||
|
||||
builder.Property(role => role.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(5);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Common.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Configures the entity mapping for the <see cref="RolePermissionEntity"/> entity.
|
||||
/// </summary>
|
||||
public class RolePermissionConfiguration : IEntityTypeConfiguration<RolePermissionEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the <see cref="RolePermissionEntity"/> entity.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder to be used to configure the entity.</param>
|
||||
public void Configure(EntityTypeBuilder<RolePermissionEntity> builder)
|
||||
{
|
||||
builder.ToTable("RolePermissions");
|
||||
|
||||
// composite primary key
|
||||
builder.HasKey(rolePermission => new { rolePermission.RoleId, rolePermission.PermissionId });
|
||||
|
||||
// foreign key: Role
|
||||
builder.HasOne(rolePermission => rolePermission.Role)
|
||||
.WithMany(user => user.RolePermissions)
|
||||
.HasForeignKey(rolePermission => rolePermission.RoleId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a Role deletes associated RolePermission
|
||||
|
||||
// foreign key: Permission
|
||||
builder.HasOne(rolePermission => rolePermission.Permission)
|
||||
.WithMany(role => role.RolePermissions)
|
||||
.HasForeignKey(rolePermission => rolePermission.PermissionId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a Permission deletes associated RolePermission
|
||||
|
||||
// audit
|
||||
builder.Property(rolePermission => rolePermission.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(1);
|
||||
|
||||
builder.Property(rolePermission => rolePermission.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(2);
|
||||
|
||||
builder.Property(rolePermission => rolePermission.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(3);
|
||||
|
||||
builder.Property(rolePermission => rolePermission.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(4);
|
||||
|
||||
// indexes
|
||||
builder.HasIndex(userRole => new { userRole.RoleId, userRole.PermissionId })
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
||||
@@ -33,24 +33,53 @@ public class UserConfiguration : IEntityTypeConfiguration<UserEntity>
|
||||
.HasColumnOrder(2);
|
||||
|
||||
builder.Property(user => user.TempPassword)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(3);
|
||||
|
||||
builder.Property(user => user.TotpSecret)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(4);
|
||||
|
||||
builder.Property(user => user.VerificationToken)
|
||||
builder.Property(user => user.TempPasswordCreated)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(5);
|
||||
|
||||
builder.Property(user => user.VerificationTokenCreated)
|
||||
.HasColumnOrder(6);
|
||||
|
||||
builder.Property(user => user.TempPasswordCreated)
|
||||
.HasColumnOrder(7);
|
||||
|
||||
// relationships
|
||||
builder.HasMany(user => user.Libraries)
|
||||
.WithOne(library => library.User)
|
||||
.HasForeignKey(library => library.UserId)
|
||||
.IsRequired() // a library must have a user
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
builder.HasMany(user => user.UserRoles)
|
||||
.WithOne(userRole => userRole.User)
|
||||
.HasForeignKey(userRole => userRole.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
builder.HasMany(user => user.UserPermissions)
|
||||
.WithOne(userPermission => userPermission.User)
|
||||
.HasForeignKey(userPermission => userPermission.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// audit
|
||||
builder.Property(user => user.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(6);
|
||||
|
||||
builder.Property(user => user.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(7);
|
||||
|
||||
builder.Property(user => user.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(8);
|
||||
|
||||
builder.Property(user => user.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(9);
|
||||
|
||||
// indexes
|
||||
builder.HasIndex(user => user.Username)
|
||||
.IsUnique(); // queried frequently
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Common.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Configures the entity mapping for the <see cref="UserPermissionEntity"/> entity.
|
||||
/// </summary>
|
||||
public class UserPermissionConfiguration : IEntityTypeConfiguration<UserPermissionEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the <see cref="UserPermissionEntity"/> entity.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder to be used to configure the entity.</param>
|
||||
public void Configure(EntityTypeBuilder<UserPermissionEntity> builder)
|
||||
{
|
||||
builder.ToTable("UserPermissions");
|
||||
|
||||
// composite primary key
|
||||
builder.HasKey(userPermission => new { userPermission.UserId, userPermission.PermissionId });
|
||||
|
||||
// foreign key: User
|
||||
builder.HasOne(userPermission => userPermission.User)
|
||||
.WithMany(user => user.UserPermissions)
|
||||
.HasForeignKey(userPermission => userPermission.UserId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a User deletes associated UserPermissions
|
||||
|
||||
// foreign key: Permission
|
||||
builder.HasOne(userPermission => userPermission.Permission)
|
||||
.WithMany(role => role.UserPermissions)
|
||||
.HasForeignKey(userPermission => userPermission.PermissionId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a Permission deletes associated UserPermissions
|
||||
|
||||
// audit
|
||||
builder.Property(userPermission => userPermission.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(1);
|
||||
|
||||
builder.Property(userPermission => userPermission.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(2);
|
||||
|
||||
builder.Property(userPermission => userPermission.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(3);
|
||||
|
||||
builder.Property(userPermission => userPermission.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(4);
|
||||
|
||||
// indexes
|
||||
builder.HasIndex(userRole => new { userRole.UserId, userRole.PermissionId })
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Common.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Configures the entity mapping for the <see cref="UserRoleEntity"/> entity.
|
||||
/// </summary>
|
||||
public class UserRoleConfiguration : IEntityTypeConfiguration<UserRoleEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the <see cref="UserRoleEntity"/> entity.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder to be used to configure the entity.</param>
|
||||
public void Configure(EntityTypeBuilder<UserRoleEntity> builder)
|
||||
{
|
||||
builder.ToTable("UserRoles");
|
||||
|
||||
// composite primary key
|
||||
builder.HasKey(userRole => new { userRole.UserId, userRole.RoleId });
|
||||
|
||||
// foreign key: User
|
||||
builder.HasOne(userRole => userRole.User)
|
||||
.WithMany(user => user.UserRoles)
|
||||
.HasForeignKey(userRole => userRole.UserId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a User deletes associated UserRoles
|
||||
|
||||
// foreign key: Role
|
||||
builder.HasOne(userRole => userRole.Role)
|
||||
.WithMany(role => role.UserRoles)
|
||||
.HasForeignKey(userRole => userRole.RoleId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a Role deletes associated UserRoles
|
||||
|
||||
// audit
|
||||
builder.Property(userRole => userRole.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(1);
|
||||
|
||||
builder.Property(userRole => userRole.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(2);
|
||||
|
||||
builder.Property(userRole => userRole.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(3);
|
||||
|
||||
builder.Property(userRole => userRole.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(4);
|
||||
|
||||
// indexes
|
||||
builder.HasIndex(userRole => new { userRole.UserId, userRole.RoleId })
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.DataAccess.Common.Interceptors;
|
||||
using Lumina.DataAccess.Core.Repositories.Common.Factory;
|
||||
using Lumina.DataAccess.Core.UoW;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -31,11 +32,13 @@ public static class DataAccessLayerServices
|
||||
string? basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
if (!Directory.Exists(basePath))
|
||||
throw new DirectoryNotFoundException($"The base path '{basePath}' does not exist.");
|
||||
services.AddDbContext<LuminaDbContext>(options =>
|
||||
services.AddDbContext<LuminaDbContext>((serviceProvider, options) =>
|
||||
{
|
||||
options.UseSqlite($"Data Source={Path.Combine(basePath, "Lumina.db")}");
|
||||
options.AddInterceptors(serviceProvider.GetRequiredService<UpdateAuditableEntitiesInterceptor>());
|
||||
});
|
||||
services.AddScoped<IUnitOfWork, UnitOfWork>();
|
||||
services.AddScoped<UpdateAuditableEntitiesInterceptor>();
|
||||
|
||||
Type[]? dataAccessLayerTypes = Assembly.GetExecutingAssembly().GetTypes();
|
||||
Type? genericRepositoryType = typeof(IRepository<>);
|
||||
@@ -45,16 +48,16 @@ public static class DataAccessLayerServices
|
||||
services.AddScoped(iRepositoryFactoryType!, repositoryFactoryType!);
|
||||
|
||||
// get all classes implementing IRepository (all repository classes) and register them as their corresponding repository interface
|
||||
IEnumerable<Type> repositoryTypes = dataAccessLayerTypes.Where(t => !t.IsInterface &&
|
||||
t.GetInterfaces()
|
||||
.Any(i => i.IsGenericType &&
|
||||
i.GetGenericTypeDefinition() == genericRepositoryType));
|
||||
IEnumerable<Type> repositoryTypes = dataAccessLayerTypes.Where(type => !type.IsInterface &&
|
||||
type.GetInterfaces()
|
||||
.Any(type => type.IsGenericType &&
|
||||
type.GetGenericTypeDefinition() == genericRepositoryType));
|
||||
foreach (Type type in repositoryTypes)
|
||||
{
|
||||
services.AddScoped(type.GetInterfaces() // TODO: change to scoped when DbContext is implemented
|
||||
.Where(i => !i.IsGenericType &&
|
||||
i.GetInterfaces()
|
||||
.Any(j => j.GetGenericTypeDefinition() == genericRepositoryType))
|
||||
.Where(type => !type.IsGenericType &&
|
||||
type.GetInterfaces()
|
||||
.Any(type => type.GetGenericTypeDefinition() == genericRepositoryType))
|
||||
.First(), type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Time;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Common.Interceptors;
|
||||
|
||||
/// <summary>
|
||||
/// Interceptor for updating audit fields automatically for entities implementing <see cref="IAuditableEntity"/>.
|
||||
/// </summary>
|
||||
public sealed class UpdateAuditableEntitiesInterceptor : SaveChangesInterceptor
|
||||
{
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly IDateTimeProvider _dateTimeProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateAuditableEntitiesInterceptor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
|
||||
/// <param name="dateTimeProvider">Injected service for time related functionality.</param>
|
||||
public UpdateAuditableEntitiesInterceptor(ICurrentUserService currentUserService, IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
_currentUserService = currentUserService;
|
||||
_dateTimeProvider = dateTimeProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intercepts the synchronous SaveChanges operation to update audit fields.
|
||||
/// </summary>
|
||||
/// <param name="eventData">The event data containing the <see cref="DbContext"/>.</param>
|
||||
/// <param name="result">The result of the SaveChanges operation.</param>
|
||||
/// <returns>The interception result.</returns>
|
||||
public override InterceptionResult<int> SavingChanges(DbContextEventData eventData, InterceptionResult<int> result)
|
||||
{
|
||||
UpdateAuditableEntities(eventData.Context);
|
||||
return base.SavingChanges(eventData, result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intercepts the asynchronous SaveChangesAsync operation to update audit fields.
|
||||
/// </summary>
|
||||
/// <param name="eventData">The event data containing the <see cref="DbContext"/>.</param>
|
||||
/// <param name="result">The result of the SaveChanges operation.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>A <see cref="ValueTask"/> containing the interception result.</returns>
|
||||
public override ValueTask<InterceptionResult<int>> SavingChangesAsync(DbContextEventData eventData, InterceptionResult<int> result, CancellationToken cancellationToken = default)
|
||||
{
|
||||
UpdateAuditableEntities(eventData.Context);
|
||||
return base.SavingChangesAsync(eventData, result, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the audit fields for all changed entities that implement IAuditableEntity.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="DbContext"/> containing the entities to update.</param>
|
||||
private void UpdateAuditableEntities(DbContext? context)
|
||||
{
|
||||
if (context is null)
|
||||
return;
|
||||
|
||||
Guid? userId = _currentUserService.UserId;
|
||||
DateTime utcNow = _dateTimeProvider.UtcNow;
|
||||
|
||||
// retrieve all entities implementing IAuditableEntity that are being tracked and have either Added or Modified state
|
||||
foreach (EntityEntry<IAuditableEntity> entry in context.ChangeTracker.Entries<IAuditableEntity>())
|
||||
{
|
||||
if (entry.State == EntityState.Added)
|
||||
SetCreationProperties(entry.Entity, userId, utcNow);
|
||||
else if(entry.State == EntityState.Modified)
|
||||
SetModificationProperties(entry, userId, utcNow);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the creation audit properties for a newly added entity.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity being created.</param>
|
||||
/// <param name="userId">The Id of the user creating the entity.</param>
|
||||
/// <param name="utcNow">The current UTC timestamp.</param>
|
||||
private static void SetCreationProperties(IAuditableEntity entity, Guid? userId, DateTime utcNow)
|
||||
{
|
||||
entity.CreatedOnUtc = utcNow;
|
||||
entity.CreatedBy = userId ?? default;
|
||||
entity.UpdatedOnUtc = null;
|
||||
entity.UpdatedBy = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the modification audit properties for an updated entity while protecting creation properties.
|
||||
/// </summary>
|
||||
/// <param name="entry">The entity entry being modified.</param>
|
||||
/// <param name="userId">The Id of the user modifying the entity.</param>
|
||||
/// <param name="utcNow">The current UTC timestamp.</param>
|
||||
private static void SetModificationProperties(EntityEntry<IAuditableEntity> entry, Guid? userId, DateTime utcNow)
|
||||
{
|
||||
// prevent modification of creation properties
|
||||
entry.Property(auditableEntity => auditableEntity.CreatedOnUtc).IsModified = false;
|
||||
entry.Property(auditableEntity => auditableEntity.CreatedBy).IsModified = false;
|
||||
|
||||
// set modification properties
|
||||
entry.Entity.UpdatedOnUtc = utcNow;
|
||||
entry.Entity.UpdatedBy = userId;
|
||||
}
|
||||
}
|
||||
+706
@@ -0,0 +1,706 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Lumina.DataAccess.Core.UoW;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lumina.DataAccess.Common.Migrations
|
||||
{
|
||||
[DbContext(typeof(LuminaDbContext))]
|
||||
[Migration("20241122152616_AddRolesAndPermissions")]
|
||||
partial class AddRolesAndPermissions
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
|
||||
|
||||
modelBuilder.Entity("BookGenres", b =>
|
||||
{
|
||||
b.Property<Guid>("BookId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("GenreId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("BookId", "GenreId");
|
||||
|
||||
b.HasIndex("GenreId");
|
||||
|
||||
b.ToTable("BookGenres", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BookTags", b =>
|
||||
{
|
||||
b.Property<Guid>("BookId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("TagId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("BookId", "TagId");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("BookTags", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<string>("PermissionName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(5);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Permissions", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<string>("RoleName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(5);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("RoleId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("PermissionId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.HasKey("RoleId", "PermissionId");
|
||||
|
||||
b.HasIndex("PermissionId");
|
||||
|
||||
b.HasIndex("RoleId", "PermissionId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("RolePermissions", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("PermissionId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.HasKey("UserId", "PermissionId");
|
||||
|
||||
b.HasIndex("PermissionId");
|
||||
|
||||
b.HasIndex("UserId", "PermissionId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("UserPermissions", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("RoleId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.HasIndex("UserId", "RoleId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("UserRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", b =>
|
||||
{
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Name");
|
||||
|
||||
b.ToTable("Genres", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", b =>
|
||||
{
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Name");
|
||||
|
||||
b.ToTable("Tags", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LibraryType")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<DateTime?>("Updated")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Libraries", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<string>("ASIN")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(21);
|
||||
|
||||
b.Property<string>("AppleBooksId")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(29);
|
||||
|
||||
b.Property<string>("BarnesAndNobleId")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(28);
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(30);
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<string>("Edition")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(19);
|
||||
|
||||
b.Property<string>("Format")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(18);
|
||||
|
||||
b.Property<string>("GoodreadsId")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(22);
|
||||
|
||||
b.Property<string>("GoogleBooksId")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(27);
|
||||
|
||||
b.Property<string>("LCCN")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(23);
|
||||
|
||||
b.Property<string>("LanguageCode")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(10);
|
||||
|
||||
b.Property<string>("LanguageName")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(11);
|
||||
|
||||
b.Property<string>("LanguageNativeName")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(12);
|
||||
|
||||
b.Property<string>("LibraryThingId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(26);
|
||||
|
||||
b.Property<string>("OCLCNumber")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(24);
|
||||
|
||||
b.Property<string>("OpenLibraryId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(25);
|
||||
|
||||
b.Property<string>("OriginalLanguageCode")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(13);
|
||||
|
||||
b.Property<string>("OriginalLanguageName")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(14);
|
||||
|
||||
b.Property<string>("OriginalLanguageNativeName")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(15);
|
||||
|
||||
b.Property<DateOnly?>("OriginalReleaseDate")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<int?>("OriginalReleaseYear")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(5);
|
||||
|
||||
b.Property<string>("OriginalTitle")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<int?>("PageCount")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(17);
|
||||
|
||||
b.Property<string>("Publisher")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(16);
|
||||
|
||||
b.Property<DateOnly?>("ReReleaseDate")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(6);
|
||||
|
||||
b.Property<int?>("ReReleaseYear")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(7);
|
||||
|
||||
b.Property<string>("ReleaseCountry")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(8);
|
||||
|
||||
b.Property<string>("ReleaseVersion")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(9);
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<DateTime?>("Updated")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(31);
|
||||
|
||||
b.Property<int?>("VolumeNumber")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(20);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Books", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(7);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(6);
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<string>("TempPassword")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<DateTime?>("TempPasswordCreated")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(5);
|
||||
|
||||
b.Property<string>("TotpSecret")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(9);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(8);
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Username")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Users", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BookGenres", b =>
|
||||
{
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("BookId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("GenreId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BookTags", b =>
|
||||
{
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("BookId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TagId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
|
||||
{
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
|
||||
.WithMany("RolePermissions")
|
||||
.HasForeignKey("PermissionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
|
||||
.WithMany("RolePermissions")
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Permission");
|
||||
|
||||
b.Navigation("Role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
|
||||
{
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
|
||||
.WithMany("UserPermissions")
|
||||
.HasForeignKey("PermissionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
|
||||
.WithMany("UserPermissions")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Permission");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
|
||||
{
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
|
||||
.WithMany("UserRoles")
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
|
||||
.WithMany("UserRoles")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Role");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
|
||||
{
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
|
||||
.WithMany("Libraries")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryContentLocationEntity", "ContentLocations", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<Guid>("LibraryId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<string>("Path")
|
||||
.IsRequired()
|
||||
.HasMaxLength(260)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("Path");
|
||||
|
||||
b1.HasKey("Id");
|
||||
|
||||
b1.HasIndex("LibraryId");
|
||||
|
||||
b1.ToTable("LibraryContentLocations", (string)null);
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("LibraryId");
|
||||
});
|
||||
|
||||
b.Navigation("ContentLocations");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
|
||||
{
|
||||
b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookRatingEntity", "Ratings", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<Guid>("BookId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<decimal>("MaxValue")
|
||||
.HasColumnType("decimal(3,2)");
|
||||
|
||||
b1.Property<string>("Source")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<decimal>("Value")
|
||||
.HasColumnType("decimal(3,2)");
|
||||
|
||||
b1.Property<int?>("VoteCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b1.HasKey("Id");
|
||||
|
||||
b1.HasIndex("BookId");
|
||||
|
||||
b1.ToTable("BookRatings", (string)null);
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("BookId");
|
||||
});
|
||||
|
||||
b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.IsbnEntity", "ISBNs", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<Guid>("BookId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<string>("Format")
|
||||
.IsRequired()
|
||||
.HasMaxLength(6)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasMaxLength(13)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("ISBN");
|
||||
|
||||
b1.HasKey("Id");
|
||||
|
||||
b1.HasIndex("BookId");
|
||||
|
||||
b1.ToTable("BookISBNs", (string)null);
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("BookId");
|
||||
});
|
||||
|
||||
b.Navigation("ISBNs");
|
||||
|
||||
b.Navigation("Ratings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
|
||||
{
|
||||
b.Navigation("RolePermissions");
|
||||
|
||||
b.Navigation("UserPermissions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
|
||||
{
|
||||
b.Navigation("RolePermissions");
|
||||
|
||||
b.Navigation("UserRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
|
||||
{
|
||||
b.Navigation("Libraries");
|
||||
|
||||
b.Navigation("UserPermissions");
|
||||
|
||||
b.Navigation("UserRoles");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lumina.DataAccess.Common.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class AddRolesAndPermissions : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Updated",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "VerificationTokenCreated",
|
||||
table: "Users",
|
||||
newName: "UpdatedOnUtc");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "VerificationToken",
|
||||
table: "Users",
|
||||
newName: "UpdatedBy");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Created",
|
||||
table: "Users",
|
||||
newName: "CreatedOnUtc");
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "TempPasswordCreated",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 5)
|
||||
.OldAnnotation("Relational:ColumnOrder", 7);
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "UpdatedOnUtc",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 8)
|
||||
.OldAnnotation("Relational:ColumnOrder", 6);
|
||||
|
||||
migrationBuilder.AlterColumn<Guid>(
|
||||
name: "UpdatedBy",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 9)
|
||||
.OldAnnotation("Relational:ColumnOrder", 5);
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "CreatedOnUtc",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT")
|
||||
.Annotation("Relational:ColumnOrder", 6);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "CreatedBy",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"))
|
||||
.Annotation("Relational:ColumnOrder", 7);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Permissions",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
PermissionName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
|
||||
CreatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
CreatedBy = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
UpdatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
UpdatedBy = table.Column<Guid>(type: "TEXT", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Permissions", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Roles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
RoleName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
|
||||
CreatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
CreatedBy = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
UpdatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
UpdatedBy = table.Column<Guid>(type: "TEXT", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Roles", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UserPermissions",
|
||||
columns: table => new
|
||||
{
|
||||
CreatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
CreatedBy = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
UpdatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
UpdatedBy = table.Column<Guid>(type: "TEXT", nullable: true),
|
||||
UserId = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
PermissionId = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
Id = table.Column<Guid>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UserPermissions", x => new { x.UserId, x.PermissionId });
|
||||
table.ForeignKey(
|
||||
name: "FK_UserPermissions_Permissions_PermissionId",
|
||||
column: x => x.PermissionId,
|
||||
principalTable: "Permissions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_UserPermissions_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RolePermissions",
|
||||
columns: table => new
|
||||
{
|
||||
CreatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
CreatedBy = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
UpdatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
UpdatedBy = table.Column<Guid>(type: "TEXT", nullable: true),
|
||||
RoleId = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
PermissionId = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
Id = table.Column<Guid>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RolePermissions", x => new { x.RoleId, x.PermissionId });
|
||||
table.ForeignKey(
|
||||
name: "FK_RolePermissions_Permissions_PermissionId",
|
||||
column: x => x.PermissionId,
|
||||
principalTable: "Permissions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RolePermissions_Roles_RoleId",
|
||||
column: x => x.RoleId,
|
||||
principalTable: "Roles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UserRoles",
|
||||
columns: table => new
|
||||
{
|
||||
CreatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
CreatedBy = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
UpdatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
UpdatedBy = table.Column<Guid>(type: "TEXT", nullable: true),
|
||||
UserId = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
RoleId = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
Id = table.Column<Guid>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId });
|
||||
table.ForeignKey(
|
||||
name: "FK_UserRoles_Roles_RoleId",
|
||||
column: x => x.RoleId,
|
||||
principalTable: "Roles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_UserRoles_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Users_Username",
|
||||
table: "Users",
|
||||
column: "Username",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RolePermissions_PermissionId",
|
||||
table: "RolePermissions",
|
||||
column: "PermissionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RolePermissions_RoleId_PermissionId",
|
||||
table: "RolePermissions",
|
||||
columns: new[] { "RoleId", "PermissionId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserPermissions_PermissionId",
|
||||
table: "UserPermissions",
|
||||
column: "PermissionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserPermissions_UserId_PermissionId",
|
||||
table: "UserPermissions",
|
||||
columns: new[] { "UserId", "PermissionId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserRoles_RoleId",
|
||||
table: "UserRoles",
|
||||
column: "RoleId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserRoles_UserId_RoleId",
|
||||
table: "UserRoles",
|
||||
columns: new[] { "UserId", "RoleId" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "RolePermissions");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserPermissions");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserRoles");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Permissions");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Roles");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Users_Username",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreatedBy",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "UpdatedOnUtc",
|
||||
table: "Users",
|
||||
newName: "VerificationTokenCreated");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "UpdatedBy",
|
||||
table: "Users",
|
||||
newName: "VerificationToken");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "CreatedOnUtc",
|
||||
table: "Users",
|
||||
newName: "Created");
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "TempPasswordCreated",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 7)
|
||||
.OldAnnotation("Relational:ColumnOrder", 5);
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "VerificationTokenCreated",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 6)
|
||||
.OldAnnotation("Relational:ColumnOrder", 8);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "VerificationToken",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(Guid),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 5)
|
||||
.OldAnnotation("Relational:ColumnOrder", 9);
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "Created",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "TEXT")
|
||||
.OldAnnotation("Relational:ColumnOrder", 6);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "Updated",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.10");
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
|
||||
|
||||
modelBuilder.Entity("BookGenres", b =>
|
||||
{
|
||||
@@ -47,6 +47,185 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
b.ToTable("BookTags", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<string>("PermissionName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(5);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Permissions", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<string>("RoleName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(5);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("RoleId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("PermissionId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.HasKey("RoleId", "PermissionId");
|
||||
|
||||
b.HasIndex("PermissionId");
|
||||
|
||||
b.HasIndex("RoleId", "PermissionId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("RolePermissions", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("PermissionId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.HasKey("UserId", "PermissionId");
|
||||
|
||||
b.HasIndex("PermissionId");
|
||||
|
||||
b.HasIndex("UserId", "PermissionId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("UserPermissions", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("RoleId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.HasIndex("UserId", "RoleId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("UserRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", b =>
|
||||
{
|
||||
b.Property<string>("Name")
|
||||
@@ -254,8 +433,13 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(7);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(6);
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
@@ -268,14 +452,19 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
|
||||
b.Property<DateTime?>("TempPasswordCreated")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(7);
|
||||
.HasColumnOrder(5);
|
||||
|
||||
b.Property<string>("TotpSecret")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime?>("Updated")
|
||||
.HasColumnType("TEXT");
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(9);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(8);
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
@@ -283,16 +472,11 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<string>("VerificationToken")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(5);
|
||||
|
||||
b.Property<DateTime?>("VerificationTokenCreated")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(6);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Username")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Users", (string)null);
|
||||
});
|
||||
|
||||
@@ -326,6 +510,63 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
|
||||
{
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
|
||||
.WithMany("RolePermissions")
|
||||
.HasForeignKey("PermissionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
|
||||
.WithMany("RolePermissions")
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Permission");
|
||||
|
||||
b.Navigation("Role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
|
||||
{
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
|
||||
.WithMany("UserPermissions")
|
||||
.HasForeignKey("PermissionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
|
||||
.WithMany("UserPermissions")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Permission");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
|
||||
{
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
|
||||
.WithMany("UserRoles")
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
|
||||
.WithMany("UserRoles")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Role");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
|
||||
{
|
||||
b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
|
||||
@@ -375,8 +616,7 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
b1.Property<Guid>("BookId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<decimal?>("MaxValue")
|
||||
.IsRequired()
|
||||
b1.Property<decimal>("MaxValue")
|
||||
.HasColumnType("decimal(3,2)");
|
||||
|
||||
b1.Property<string>("Source")
|
||||
@@ -384,8 +624,7 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<decimal?>("Value")
|
||||
.IsRequired()
|
||||
b1.Property<decimal>("Value")
|
||||
.HasColumnType("decimal(3,2)");
|
||||
|
||||
b1.Property<int?>("VoteCount")
|
||||
@@ -436,9 +675,27 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
b.Navigation("Ratings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
|
||||
{
|
||||
b.Navigation("RolePermissions");
|
||||
|
||||
b.Navigation("UserPermissions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
|
||||
{
|
||||
b.Navigation("RolePermissions");
|
||||
|
||||
b.Navigation("UserRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
|
||||
{
|
||||
b.Navigation("Libraries");
|
||||
|
||||
b.Navigation("UserPermissions");
|
||||
|
||||
b.Navigation("UserRoles");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user