From 5f66f2d31eec1efa5cbf3c423460c54294630625 Mon Sep 17 00:00:00 2001 From: "hualin.zhu" Date: Mon, 7 Oct 2024 19:28:56 +0800 Subject: [PATCH 01/14] add TimeZoneId LanguageCode in ApplicationUser --- .../Common/Security/UserProfile.cs | 3 + .../Identity/DTOs/ApplicationUserDto.cs | 9 +- .../Common/Entities/BaseAuditableEntity.cs | 15 +- src/Domain/Identity/ApplicationRole.cs | 8 +- src/Domain/Identity/ApplicationUser.cs | 12 +- .../AuditableEntityInterceptor.cs | 6 +- ...uditableEntity_ApplicationUser.Designer.cs | 814 +++++++++++++++++ ...110122_IAuditableEntity_ApplicationUser.cs | 61 ++ ...112447_TimeZoneId_LanguageCode.Designer.cs | 836 ++++++++++++++++++ .../20241007112447_TimeZoneId_LanguageCode.cs | 105 +++ .../ApplicationDbContextModelSnapshot.cs | 38 +- 11 files changed, 1896 insertions(+), 11 deletions(-) create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20241007110122_IAuditableEntity_ApplicationUser.Designer.cs create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20241007110122_IAuditableEntity_ApplicationUser.cs create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20241007112447_TimeZoneId_LanguageCode.Designer.cs create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20241007112447_TimeZoneId_LanguageCode.cs diff --git a/src/Application/Common/Security/UserProfile.cs b/src/Application/Common/Security/UserProfile.cs index c284f6dc5..d9d5a6c51 100644 --- a/src/Application/Common/Security/UserProfile.cs +++ b/src/Application/Common/Security/UserProfile.cs @@ -18,4 +18,7 @@ public class UserProfile public bool IsActive { get; set; } public string? TenantId { get; set; } public string? TenantName { get; set; } + + public string? TimeZoneId { get; set; } + public string? LanguageCode { get; set; } } diff --git a/src/Application/Features/Identity/DTOs/ApplicationUserDto.cs b/src/Application/Features/Identity/DTOs/ApplicationUserDto.cs index 990a2ecdd..b0a21836a 100644 --- a/src/Application/Features/Identity/DTOs/ApplicationUserDto.cs +++ b/src/Application/Features/Identity/DTOs/ApplicationUserDto.cs @@ -43,7 +43,10 @@ public class ApplicationUserDto [Description("Email Confirmed")] public bool EmailConfirmed { get; set; } [Description("Status")] public DateTimeOffset? LockoutEnd { get; set; } - + [Description("Time Zone")] + public string? TimeZoneId { get; set; } + [Description("Language")] + public string? LanguageCode { get; set; } public UserProfile ToUserProfile() { return new UserProfile @@ -60,7 +63,9 @@ public UserProfile ToUserProfile() SuperiorId = SuperiorId, SuperiorName = Superior?.UserName, AssignedRoles = AssignedRoles, - DefaultRole = DefaultRole + DefaultRole = DefaultRole, + TimeZoneId = TimeZoneId, + LanguageCode = LanguageCode }; } diff --git a/src/Domain/Common/Entities/BaseAuditableEntity.cs b/src/Domain/Common/Entities/BaseAuditableEntity.cs index a8d5a357c..e3dca9b38 100644 --- a/src/Domain/Common/Entities/BaseAuditableEntity.cs +++ b/src/Domain/Common/Entities/BaseAuditableEntity.cs @@ -1,9 +1,9 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace CleanArchitecture.Blazor.Domain.Common.Entities; -public abstract class BaseAuditableEntity : BaseEntity +public abstract class BaseAuditableEntity : BaseEntity, IAuditableEntity { public virtual DateTime? Created { get; set; } @@ -12,4 +12,15 @@ public abstract class BaseAuditableEntity : BaseEntity public virtual DateTime? LastModified { get; set; } public virtual string? LastModifiedBy { get; set; } +} + +public interface IAuditableEntity +{ + DateTime? Created { get; set; } + + string? CreatedBy { get; set; } + + DateTime? LastModified { get; set; } + + string? LastModifiedBy { get; set; } } \ No newline at end of file diff --git a/src/Domain/Identity/ApplicationRole.cs b/src/Domain/Identity/ApplicationRole.cs index c3a974583..2aee2dc97 100644 --- a/src/Domain/Identity/ApplicationRole.cs +++ b/src/Domain/Identity/ApplicationRole.cs @@ -1,9 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using CleanArchitecture.Blazor.Domain.Common.Entities; + namespace CleanArchitecture.Blazor.Domain.Identity; -public class ApplicationRole : IdentityRole +public class ApplicationRole : IdentityRole, IAuditableEntity { public ApplicationRole() { @@ -21,4 +23,8 @@ public ApplicationRole(string roleName) : base(roleName) public string? Description { get; set; } public virtual ICollection RoleClaims { get; set; } public virtual ICollection UserRoles { get; set; } + public DateTime? Created { get; set; } + public string? CreatedBy { get; set; } + public DateTime? LastModified { get; set; } + public string? LastModifiedBy { get; set; } } \ No newline at end of file diff --git a/src/Domain/Identity/ApplicationUser.cs b/src/Domain/Identity/ApplicationUser.cs index 815a16146..489d4d58f 100644 --- a/src/Domain/Identity/ApplicationUser.cs +++ b/src/Domain/Identity/ApplicationUser.cs @@ -2,10 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel.DataAnnotations.Schema; +using CleanArchitecture.Blazor.Domain.Common.Entities; namespace CleanArchitecture.Blazor.Domain.Identity; -public class ApplicationUser : IdentityUser +public class ApplicationUser : IdentityUser, IAuditableEntity { public ApplicationUser() { @@ -20,7 +21,7 @@ public ApplicationUser() public string? TenantId { get; set; } public virtual Tenant? Tenant { get; set; } - [Column(TypeName = "text")] public string? ProfilePictureDataUrl { get; set; } + public string? ProfilePictureDataUrl { get; set; } public bool IsActive { get; set; } public bool IsLive { get; set; } @@ -33,4 +34,11 @@ public ApplicationUser() public string? SuperiorId { get; set; } = null; public ApplicationUser? Superior { get; set; } = null; + public DateTime? Created { get; set; } + public string? CreatedBy { get; set; } + public DateTime? LastModified { get; set; } + public string? LastModifiedBy { get; set; } + + public string? TimeZoneId { get; set; } + public string? LanguageCode { get; set; } } \ No newline at end of file diff --git a/src/Infrastructure/Persistence/Interceptors/AuditableEntityInterceptor.cs b/src/Infrastructure/Persistence/Interceptors/AuditableEntityInterceptor.cs index 80200d5ba..07b44cfd5 100644 --- a/src/Infrastructure/Persistence/Interceptors/AuditableEntityInterceptor.cs +++ b/src/Infrastructure/Persistence/Interceptors/AuditableEntityInterceptor.cs @@ -57,7 +57,7 @@ private void UpdateAuditableEntities(DbContext context) var tenantId = _currentUserService.TenantId; var now = _dateTime.Now; - foreach (var entry in context.ChangeTracker.Entries()) + foreach (var entry in context.ChangeTracker.Entries()) { switch (entry.State) { @@ -83,7 +83,7 @@ private void UpdateAuditableEntities(DbContext context) } } - private static void SetCreationAuditInfo(BaseAuditableEntity entity, string userId, string tenantId, DateTime now) + private static void SetCreationAuditInfo(IAuditableEntity entity, string userId, string tenantId, DateTime now) { entity.CreatedBy = userId; entity.Created = now; @@ -91,7 +91,7 @@ private static void SetCreationAuditInfo(BaseAuditableEntity entity, string user if (entity is IMayHaveTenant mayTenant) mayTenant.TenantId = tenantId; } - private static void SetModificationAuditInfo(BaseAuditableEntity entity, string userId, DateTime now) + private static void SetModificationAuditInfo(IAuditableEntity entity, string userId, DateTime now) { entity.LastModifiedBy = userId; entity.LastModified = now; diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241007110122_IAuditableEntity_ApplicationUser.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241007110122_IAuditableEntity_ApplicationUser.Designer.cs new file mode 100644 index 000000000..7db006682 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241007110122_IAuditableEntity_ApplicationUser.Designer.cs @@ -0,0 +1,814 @@ +// +using System; +using CleanArchitecture.Blazor.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CleanArchitecture.Blazor.Migrators.MSSQL.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20241007110122_IAuditableEntity_ApplicationUser")] + partial class IAuditableEntity_ApplicationUser + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.AuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AffectedColumns") + .HasColumnType("nvarchar(max)"); + + b.Property("AuditType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("NewValues") + .HasColumnType("nvarchar(max)"); + + b.Property("OldValues") + .HasColumnType("nvarchar(max)"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TableName") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AuditTrails"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Contact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Country") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PhoneNumber") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.ToTable("Contacts"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("DocumentType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsPublic") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Title") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("URL") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("LastModifiedBy"); + + b.HasIndex("TenantId"); + + b.ToTable("Documents"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Logger", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientAgent") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ClientIP") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Exception") + .HasMaxLength(2147483647) + .HasColumnType("nvarchar(max)"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LogEvent") + .HasMaxLength(2147483647) + .HasColumnType("nvarchar(max)"); + + b.Property("Message") + .HasMaxLength(2147483647) + .HasColumnType("nvarchar(max)"); + + b.Property("MessageTemplate") + .HasMaxLength(2147483647) + .HasColumnType("nvarchar(max)"); + + b.Property("Properties") + .HasMaxLength(2147483647) + .HasColumnType("nvarchar(max)"); + + b.Property("TimeStamp") + .HasColumnType("datetime2"); + + b.Property("UserName") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("TimeStamp"); + + b.ToTable("Loggers"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.PicklistSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Text") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Value") + .IsUnique() + .HasFilter("[Value] IS NOT NULL"); + + b.ToTable("PicklistSets"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Brand") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("nvarchar(80)"); + + b.Property("Pictures") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("Unit") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Tenant", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.ToTable("Tenants"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.HasIndex("TenantId"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ClaimValue") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Group") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("DisplayName") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsLive") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("PhoneNumber") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("ProfilePictureDataUrl") + .HasMaxLength(450) + .HasColumnType("text"); + + b.Property("Provider") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("RefreshToken") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("RefreshTokenExpiryTime") + .HasColumnType("datetime2"); + + b.Property("SecurityStamp") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("SuperiorId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("SuperiorId"); + + b.HasIndex("TenantId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ClaimValue") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserLogin", b => + { + b.Property("LoginProvider") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserRole", b => + { + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserToken", b => + { + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FriendlyName") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Xml") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.AuditTrail", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Document", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "LastModifier") + .WithMany() + .HasForeignKey("LastModifiedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("LastModifier"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRoleClaim", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", "Role") + .WithMany("RoleClaims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Superior") + .WithMany() + .HasForeignKey("SuperiorId"); + + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Superior"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserClaim", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserLogin", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserRole", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserToken", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.Navigation("RoleClaims"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.Navigation("Logins"); + + b.Navigation("Tokens"); + + b.Navigation("UserClaims"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241007110122_IAuditableEntity_ApplicationUser.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241007110122_IAuditableEntity_ApplicationUser.cs new file mode 100644 index 000000000..2926c831b --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241007110122_IAuditableEntity_ApplicationUser.cs @@ -0,0 +1,61 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CleanArchitecture.Blazor.Migrators.MSSQL.Migrations +{ + /// + public partial class IAuditableEntity_ApplicationUser : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Created", + table: "AspNetUsers", + type: "datetime2", + nullable: true); + + migrationBuilder.AddColumn( + name: "CreatedBy", + table: "AspNetUsers", + type: "nvarchar(450)", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModified", + table: "AspNetUsers", + type: "datetime2", + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModifiedBy", + table: "AspNetUsers", + type: "nvarchar(450)", + maxLength: 450, + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Created", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "CreatedBy", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "LastModified", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "LastModifiedBy", + table: "AspNetUsers"); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241007112447_TimeZoneId_LanguageCode.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241007112447_TimeZoneId_LanguageCode.Designer.cs new file mode 100644 index 000000000..4a7cc0164 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241007112447_TimeZoneId_LanguageCode.Designer.cs @@ -0,0 +1,836 @@ +// +using System; +using CleanArchitecture.Blazor.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CleanArchitecture.Blazor.Migrators.MSSQL.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20241007112447_TimeZoneId_LanguageCode")] + partial class TimeZoneId_LanguageCode + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.AuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AffectedColumns") + .HasColumnType("nvarchar(max)"); + + b.Property("AuditType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("NewValues") + .HasColumnType("nvarchar(max)"); + + b.Property("OldValues") + .HasColumnType("nvarchar(max)"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TableName") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AuditTrails"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Contact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Country") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PhoneNumber") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.ToTable("Contacts"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("DocumentType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsPublic") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Title") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("URL") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("LastModifiedBy"); + + b.HasIndex("TenantId"); + + b.ToTable("Documents"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Logger", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientAgent") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ClientIP") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Exception") + .HasMaxLength(2147483647) + .HasColumnType("nvarchar(max)"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LogEvent") + .HasMaxLength(2147483647) + .HasColumnType("nvarchar(max)"); + + b.Property("Message") + .HasMaxLength(2147483647) + .HasColumnType("nvarchar(max)"); + + b.Property("MessageTemplate") + .HasMaxLength(2147483647) + .HasColumnType("nvarchar(max)"); + + b.Property("Properties") + .HasMaxLength(2147483647) + .HasColumnType("nvarchar(max)"); + + b.Property("TimeStamp") + .HasColumnType("datetime2"); + + b.Property("UserName") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("TimeStamp"); + + b.ToTable("Loggers"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.PicklistSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Text") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Value") + .IsUnique() + .HasFilter("[Value] IS NOT NULL"); + + b.ToTable("PicklistSets"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Brand") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("nvarchar(80)"); + + b.Property("Pictures") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("Unit") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Tenant", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.ToTable("Tenants"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.HasIndex("TenantId"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ClaimValue") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Group") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("DisplayName") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsLive") + .HasColumnType("bit"); + + b.Property("LanguageCode") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("PhoneNumber") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("ProfilePictureDataUrl") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Provider") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("RefreshToken") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("RefreshTokenExpiryTime") + .HasColumnType("datetime2"); + + b.Property("SecurityStamp") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("SuperiorId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("TimeZoneId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("SuperiorId"); + + b.HasIndex("TenantId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ClaimValue") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserLogin", b => + { + b.Property("LoginProvider") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserRole", b => + { + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserToken", b => + { + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FriendlyName") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("Xml") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.AuditTrail", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Document", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "LastModifier") + .WithMany() + .HasForeignKey("LastModifiedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("LastModifier"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRoleClaim", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", "Role") + .WithMany("RoleClaims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Superior") + .WithMany() + .HasForeignKey("SuperiorId"); + + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Superior"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserClaim", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserLogin", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserRole", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserToken", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.Navigation("RoleClaims"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.Navigation("Logins"); + + b.Navigation("Tokens"); + + b.Navigation("UserClaims"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241007112447_TimeZoneId_LanguageCode.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241007112447_TimeZoneId_LanguageCode.cs new file mode 100644 index 000000000..745a7b860 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241007112447_TimeZoneId_LanguageCode.cs @@ -0,0 +1,105 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CleanArchitecture.Blazor.Migrators.MSSQL.Migrations +{ + /// + public partial class TimeZoneId_LanguageCode : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ProfilePictureDataUrl", + table: "AspNetUsers", + type: "nvarchar(450)", + maxLength: 450, + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldMaxLength: 450, + oldNullable: true); + + migrationBuilder.AddColumn( + name: "LanguageCode", + table: "AspNetUsers", + type: "nvarchar(450)", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "TimeZoneId", + table: "AspNetUsers", + type: "nvarchar(450)", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "Created", + table: "AspNetRoles", + type: "datetime2", + nullable: true); + + migrationBuilder.AddColumn( + name: "CreatedBy", + table: "AspNetRoles", + type: "nvarchar(450)", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModified", + table: "AspNetRoles", + type: "datetime2", + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModifiedBy", + table: "AspNetRoles", + type: "nvarchar(450)", + maxLength: 450, + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LanguageCode", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "TimeZoneId", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "Created", + table: "AspNetRoles"); + + migrationBuilder.DropColumn( + name: "CreatedBy", + table: "AspNetRoles"); + + migrationBuilder.DropColumn( + name: "LastModified", + table: "AspNetRoles"); + + migrationBuilder.DropColumn( + name: "LastModifiedBy", + table: "AspNetRoles"); + + migrationBuilder.AlterColumn( + name: "ProfilePictureDataUrl", + table: "AspNetUsers", + type: "text", + maxLength: 450, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(450)", + oldMaxLength: 450, + oldNullable: true); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs index 12d898cbe..8cb4d6cb4 100644 --- a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -364,10 +364,24 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(450) .HasColumnType("nvarchar(450)"); + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + b.Property("Description") .HasMaxLength(450) .HasColumnType("nvarchar(450)"); + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + b.Property("Name") .HasMaxLength(256) .HasColumnType("nvarchar(256)"); @@ -442,6 +456,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(450) .HasColumnType("nvarchar(450)"); + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + b.Property("DisplayName") .HasMaxLength(450) .HasColumnType("nvarchar(450)"); @@ -459,6 +480,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IsLive") .HasColumnType("bit"); + b.Property("LanguageCode") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + b.Property("LockoutEnabled") .HasColumnType("bit"); @@ -486,7 +518,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ProfilePictureDataUrl") .HasMaxLength(450) - .HasColumnType("text"); + .HasColumnType("nvarchar(450)"); b.Property("Provider") .HasMaxLength(450) @@ -511,6 +543,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(450) .HasColumnType("nvarchar(450)"); + b.Property("TimeZoneId") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + b.Property("TwoFactorEnabled") .HasColumnType("bit"); From 8da1ca990ffcb129ff84b2160c3dc6bf908e74a0 Mon Sep 17 00:00:00 2001 From: "hualin.zhu" Date: Mon, 7 Oct 2024 19:34:12 +0800 Subject: [PATCH 02/14] add LanguageCode and TimeZoneId in seed --- .../Persistence/ApplicationDbContextInitializer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Infrastructure/Persistence/ApplicationDbContextInitializer.cs b/src/Infrastructure/Persistence/ApplicationDbContextInitializer.cs index 6e2ce12fe..3678880d2 100644 --- a/src/Infrastructure/Persistence/ApplicationDbContextInitializer.cs +++ b/src/Infrastructure/Persistence/ApplicationDbContextInitializer.cs @@ -149,6 +149,8 @@ private async Task SeedUsersAsync() Email = "admin@example.com", EmailConfirmed = true, ProfilePictureDataUrl = "https://s.gravatar.com/avatar/78be68221020124c23c665ac54e07074?s=80", + LanguageCode="en-US", + TimeZoneId= "Asia/Shanghai", TwoFactorEnabled = false }; @@ -161,6 +163,8 @@ private async Task SeedUsersAsync() DisplayName = UserName.Demo, Email = "demo@example.com", EmailConfirmed = true, + LanguageCode = "de-DE", + TimeZoneId = "Europe/Berlin", ProfilePictureDataUrl = "https://s.gravatar.com/avatar/ea753b0b0f357a41491408307ade445e?s=80" }; From 4f212ba1cb0b12c3497f718391df91aaa395f159 Mon Sep 17 00:00:00 2001 From: "hualin.zhu" Date: Mon, 7 Oct 2024 19:39:07 +0800 Subject: [PATCH 03/14] add migration TimeZoneId_LanguageCode --- ...113739_TimeZoneId_LanguageCode.Designer.cs | 1006 +++++++++++++++++ .../20241007113739_TimeZoneId_LanguageCode.cs | 147 +++ .../ApplicationDbContextModelSnapshot.cs | 48 +- ...113815_TimeZoneId_LanguageCode.Designer.cs | 810 +++++++++++++ .../20241007113815_TimeZoneId_LanguageCode.cs | 147 +++ .../ApplicationDbContextModelSnapshot.cs | 38 +- src/Server.UI/appsettings.json | 4 +- 7 files changed, 2196 insertions(+), 4 deletions(-) create mode 100644 src/Migrators/Migrators.PostgreSQL/Migrations/20241007113739_TimeZoneId_LanguageCode.Designer.cs create mode 100644 src/Migrators/Migrators.PostgreSQL/Migrations/20241007113739_TimeZoneId_LanguageCode.cs create mode 100644 src/Migrators/Migrators.SqLite/Migrations/20241007113815_TimeZoneId_LanguageCode.Designer.cs create mode 100644 src/Migrators/Migrators.SqLite/Migrations/20241007113815_TimeZoneId_LanguageCode.cs diff --git a/src/Migrators/Migrators.PostgreSQL/Migrations/20241007113739_TimeZoneId_LanguageCode.Designer.cs b/src/Migrators/Migrators.PostgreSQL/Migrations/20241007113739_TimeZoneId_LanguageCode.Designer.cs new file mode 100644 index 000000000..6764f42ca --- /dev/null +++ b/src/Migrators/Migrators.PostgreSQL/Migrations/20241007113739_TimeZoneId_LanguageCode.Designer.cs @@ -0,0 +1,1006 @@ +// +using System; +using CleanArchitecture.Blazor.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace CleanArchitecture.Blazor.Migrators.PostgreSQL.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20241007113739_TimeZoneId_LanguageCode")] + partial class TimeZoneId_LanguageCode + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.AuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AffectedColumns") + .HasColumnType("text") + .HasColumnName("affected_columns"); + + b.Property("AuditType") + .IsRequired() + .HasColumnType("text") + .HasColumnName("audit_type"); + + b.Property("DateTime") + .HasColumnType("timestamp without time zone") + .HasColumnName("date_time"); + + b.Property("NewValues") + .HasColumnType("text") + .HasColumnName("new_values"); + + b.Property("OldValues") + .HasColumnType("text") + .HasColumnName("old_values"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("text") + .HasColumnName("primary_key"); + + b.Property("TableName") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("table_name"); + + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("user_id"); + + b.HasKey("Id") + .HasName("pk_audit_trails"); + + b.HasIndex("UserId") + .HasDatabaseName("ix_audit_trails_user_id"); + + b.ToTable("audit_trails", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Contact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Country") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("country"); + + b.Property("Created") + .HasColumnType("timestamp without time zone") + .HasColumnName("created"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("created_by"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("description"); + + b.Property("Email") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("email"); + + b.Property("LastModified") + .HasColumnType("timestamp without time zone") + .HasColumnName("last_modified"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("last_modified_by"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("name"); + + b.Property("PhoneNumber") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("phone_number"); + + b.HasKey("Id") + .HasName("pk_contacts"); + + b.ToTable("contacts", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Content") + .HasMaxLength(4000) + .HasColumnType("character varying(4000)") + .HasColumnName("content"); + + b.Property("Created") + .HasColumnType("timestamp without time zone") + .HasColumnName("created"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("created_by"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("description"); + + b.Property("DocumentType") + .IsRequired() + .HasColumnType("text") + .HasColumnName("document_type"); + + b.Property("IsPublic") + .HasColumnType("boolean") + .HasColumnName("is_public"); + + b.Property("LastModified") + .HasColumnType("timestamp without time zone") + .HasColumnName("last_modified"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("last_modified_by"); + + b.Property("Status") + .HasColumnType("integer") + .HasColumnName("status"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("tenant_id"); + + b.Property("Title") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("title"); + + b.Property("URL") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("url"); + + b.HasKey("Id") + .HasName("pk_documents"); + + b.HasIndex("CreatedBy") + .HasDatabaseName("ix_documents_created_by"); + + b.HasIndex("LastModifiedBy") + .HasDatabaseName("ix_documents_last_modified_by"); + + b.HasIndex("TenantId") + .HasDatabaseName("ix_documents_tenant_id"); + + b.ToTable("documents", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Logger", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClientAgent") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("client_agent"); + + b.Property("ClientIP") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("client_ip"); + + b.Property("Exception") + .HasMaxLength(2147483647) + .HasColumnType("text") + .HasColumnName("exception"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("level"); + + b.Property("LogEvent") + .HasMaxLength(2147483647) + .HasColumnType("text") + .HasColumnName("log_event"); + + b.Property("Message") + .HasMaxLength(2147483647) + .HasColumnType("text") + .HasColumnName("message"); + + b.Property("MessageTemplate") + .HasMaxLength(2147483647) + .HasColumnType("text") + .HasColumnName("message_template"); + + b.Property("Properties") + .HasMaxLength(2147483647) + .HasColumnType("text") + .HasColumnName("properties"); + + b.Property("TimeStamp") + .HasColumnType("timestamp without time zone") + .HasColumnName("time_stamp"); + + b.Property("UserName") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("user_name"); + + b.HasKey("Id") + .HasName("pk_loggers"); + + b.HasIndex("Level") + .HasDatabaseName("ix_loggers_level"); + + b.HasIndex("TimeStamp") + .HasDatabaseName("ix_loggers_time_stamp"); + + b.ToTable("loggers", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.PicklistSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("timestamp without time zone") + .HasColumnName("created"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("created_by"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("description"); + + b.Property("LastModified") + .HasColumnType("timestamp without time zone") + .HasColumnName("last_modified"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("last_modified_by"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)") + .HasColumnName("name"); + + b.Property("Text") + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("text"); + + b.Property("Value") + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("value"); + + b.HasKey("Id") + .HasName("pk_picklist_sets"); + + b.HasIndex("Name", "Value") + .IsUnique() + .HasDatabaseName("ix_picklist_sets_name_value"); + + b.ToTable("picklist_sets", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Brand") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("brand"); + + b.Property("Created") + .HasColumnType("timestamp without time zone") + .HasColumnName("created"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("created_by"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("description"); + + b.Property("LastModified") + .HasColumnType("timestamp without time zone") + .HasColumnName("last_modified"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("last_modified_by"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("character varying(80)") + .HasColumnName("name"); + + b.Property("Pictures") + .HasColumnType("text") + .HasColumnName("pictures"); + + b.Property("Price") + .HasColumnType("numeric") + .HasColumnName("price"); + + b.Property("Unit") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("unit"); + + b.HasKey("Id") + .HasName("pk_products"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("ix_products_name"); + + b.ToTable("products", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Tenant", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("id"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("description"); + + b.Property("Name") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("name"); + + b.HasKey("Id") + .HasName("pk_tenants"); + + b.ToTable("tenants", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("id"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("concurrency_stamp"); + + b.Property("Created") + .HasColumnType("timestamp without time zone") + .HasColumnName("created"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("created_by"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("description"); + + b.Property("LastModified") + .HasColumnType("timestamp without time zone") + .HasColumnName("last_modified"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("last_modified_by"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasColumnName("name"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasColumnName("normalized_name"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("tenant_id"); + + b.HasKey("Id") + .HasName("pk_asp_net_roles"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.HasIndex("TenantId") + .HasDatabaseName("ix_asp_net_roles_tenant_id"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("claim_type"); + + b.Property("ClaimValue") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("claim_value"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("description"); + + b.Property("Group") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("group"); + + b.Property("RoleId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("role_id"); + + b.HasKey("Id") + .HasName("pk_asp_net_role_claims"); + + b.HasIndex("RoleId") + .HasDatabaseName("ix_asp_net_role_claims_role_id"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("id"); + + b.Property("AccessFailedCount") + .HasColumnType("integer") + .HasColumnName("access_failed_count"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("concurrency_stamp"); + + b.Property("Created") + .HasColumnType("timestamp without time zone") + .HasColumnName("created"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("created_by"); + + b.Property("DisplayName") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("display_name"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasColumnName("email"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean") + .HasColumnName("email_confirmed"); + + b.Property("IsActive") + .HasColumnType("boolean") + .HasColumnName("is_active"); + + b.Property("IsLive") + .HasColumnType("boolean") + .HasColumnName("is_live"); + + b.Property("LanguageCode") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("language_code"); + + b.Property("LastModified") + .HasColumnType("timestamp without time zone") + .HasColumnName("last_modified"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("last_modified_by"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean") + .HasColumnName("lockout_enabled"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone") + .HasColumnName("lockout_end"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasColumnName("normalized_email"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasColumnName("normalized_user_name"); + + b.Property("PasswordHash") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("password_hash"); + + b.Property("PhoneNumber") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("phone_number"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean") + .HasColumnName("phone_number_confirmed"); + + b.Property("ProfilePictureDataUrl") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("profile_picture_data_url"); + + b.Property("Provider") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("provider"); + + b.Property("RefreshToken") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("refresh_token"); + + b.Property("RefreshTokenExpiryTime") + .HasColumnType("timestamp without time zone") + .HasColumnName("refresh_token_expiry_time"); + + b.Property("SecurityStamp") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("security_stamp"); + + b.Property("SuperiorId") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("superior_id"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("tenant_id"); + + b.Property("TimeZoneId") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("time_zone_id"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean") + .HasColumnName("two_factor_enabled"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasColumnName("user_name"); + + b.HasKey("Id") + .HasName("pk_asp_net_users"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.HasIndex("SuperiorId") + .HasDatabaseName("ix_asp_net_users_superior_id"); + + b.HasIndex("TenantId") + .HasDatabaseName("ix_asp_net_users_tenant_id"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("claim_type"); + + b.Property("ClaimValue") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("claim_value"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("description"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("user_id"); + + b.HasKey("Id") + .HasName("pk_asp_net_user_claims"); + + b.HasIndex("UserId") + .HasDatabaseName("ix_asp_net_user_claims_user_id"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserLogin", b => + { + b.Property("LoginProvider") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("login_provider"); + + b.Property("ProviderKey") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("provider_key"); + + b.Property("ProviderDisplayName") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("provider_display_name"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("user_id"); + + b.HasKey("LoginProvider", "ProviderKey") + .HasName("pk_asp_net_user_logins"); + + b.HasIndex("UserId") + .HasDatabaseName("ix_asp_net_user_logins_user_id"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserRole", b => + { + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("user_id"); + + b.Property("RoleId") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("role_id"); + + b.HasKey("UserId", "RoleId") + .HasName("pk_asp_net_user_roles"); + + b.HasIndex("RoleId") + .HasDatabaseName("ix_asp_net_user_roles_role_id"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserToken", b => + { + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("user_id"); + + b.Property("LoginProvider") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("login_provider"); + + b.Property("Name") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("name"); + + b.Property("Value") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("value"); + + b.HasKey("UserId", "LoginProvider", "Name") + .HasName("pk_asp_net_user_tokens"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FriendlyName") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("friendly_name"); + + b.Property("Xml") + .HasMaxLength(4000) + .HasColumnType("character varying(4000)") + .HasColumnName("xml"); + + b.HasKey("Id") + .HasName("pk_data_protection_keys"); + + b.ToTable("data_protection_keys", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.AuditTrail", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull) + .HasConstraintName("fk_audit_trails_asp_net_users_user_id"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Document", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict) + .HasConstraintName("fk_documents_users_created_by"); + + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "LastModifier") + .WithMany() + .HasForeignKey("LastModifiedBy") + .OnDelete(DeleteBehavior.Restrict) + .HasConstraintName("fk_documents_users_last_modified_by"); + + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .HasConstraintName("fk_documents_tenants_tenant_id"); + + b.Navigation("LastModifier"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .HasConstraintName("fk_asp_net_roles_tenants_tenant_id"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRoleClaim", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", "Role") + .WithMany("RoleClaims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_asp_net_role_claims_asp_net_roles_role_id"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Superior") + .WithMany() + .HasForeignKey("SuperiorId") + .HasConstraintName("fk_asp_net_users_asp_net_users_superior_id"); + + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .HasConstraintName("fk_asp_net_users_tenants_tenant_id"); + + b.Navigation("Superior"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserClaim", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_asp_net_user_claims_asp_net_users_user_id"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserLogin", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_asp_net_user_logins_asp_net_users_user_id"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserRole", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_asp_net_user_roles_asp_net_roles_role_id"); + + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_asp_net_user_roles_asp_net_users_user_id"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserToken", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_asp_net_user_tokens_asp_net_users_user_id"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.Navigation("RoleClaims"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.Navigation("Logins"); + + b.Navigation("Tokens"); + + b.Navigation("UserClaims"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrators/Migrators.PostgreSQL/Migrations/20241007113739_TimeZoneId_LanguageCode.cs b/src/Migrators/Migrators.PostgreSQL/Migrations/20241007113739_TimeZoneId_LanguageCode.cs new file mode 100644 index 000000000..c63e1be53 --- /dev/null +++ b/src/Migrators/Migrators.PostgreSQL/Migrations/20241007113739_TimeZoneId_LanguageCode.cs @@ -0,0 +1,147 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CleanArchitecture.Blazor.Migrators.PostgreSQL.Migrations +{ + /// + public partial class TimeZoneId_LanguageCode : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "profile_picture_data_url", + table: "AspNetUsers", + type: "character varying(450)", + maxLength: 450, + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldMaxLength: 450, + oldNullable: true); + + migrationBuilder.AddColumn( + name: "created", + table: "AspNetUsers", + type: "timestamp without time zone", + nullable: true); + + migrationBuilder.AddColumn( + name: "created_by", + table: "AspNetUsers", + type: "character varying(450)", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "language_code", + table: "AspNetUsers", + type: "character varying(450)", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "last_modified", + table: "AspNetUsers", + type: "timestamp without time zone", + nullable: true); + + migrationBuilder.AddColumn( + name: "last_modified_by", + table: "AspNetUsers", + type: "character varying(450)", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "time_zone_id", + table: "AspNetUsers", + type: "character varying(450)", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "created", + table: "AspNetRoles", + type: "timestamp without time zone", + nullable: true); + + migrationBuilder.AddColumn( + name: "created_by", + table: "AspNetRoles", + type: "character varying(450)", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "last_modified", + table: "AspNetRoles", + type: "timestamp without time zone", + nullable: true); + + migrationBuilder.AddColumn( + name: "last_modified_by", + table: "AspNetRoles", + type: "character varying(450)", + maxLength: 450, + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "created", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "created_by", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "language_code", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "last_modified", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "last_modified_by", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "time_zone_id", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "created", + table: "AspNetRoles"); + + migrationBuilder.DropColumn( + name: "created_by", + table: "AspNetRoles"); + + migrationBuilder.DropColumn( + name: "last_modified", + table: "AspNetRoles"); + + migrationBuilder.DropColumn( + name: "last_modified_by", + table: "AspNetRoles"); + + migrationBuilder.AlterColumn( + name: "profile_picture_data_url", + table: "AspNetUsers", + type: "text", + maxLength: 450, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(450)", + oldMaxLength: 450, + oldNullable: true); + } + } +} diff --git a/src/Migrators/Migrators.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Migrators/Migrators.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs index 67e4271a8..dbbe6a8d4 100644 --- a/src/Migrators/Migrators.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Migrators/Migrators.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -446,11 +446,29 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("character varying(450)") .HasColumnName("concurrency_stamp"); + b.Property("Created") + .HasColumnType("timestamp without time zone") + .HasColumnName("created"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("created_by"); + b.Property("Description") .HasMaxLength(450) .HasColumnType("character varying(450)") .HasColumnName("description"); + b.Property("LastModified") + .HasColumnType("timestamp without time zone") + .HasColumnName("last_modified"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("last_modified_by"); + b.Property("Name") .HasMaxLength(256) .HasColumnType("character varying(256)") @@ -540,6 +558,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("character varying(450)") .HasColumnName("concurrency_stamp"); + b.Property("Created") + .HasColumnType("timestamp without time zone") + .HasColumnName("created"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("created_by"); + b.Property("DisplayName") .HasMaxLength(450) .HasColumnType("character varying(450)") @@ -562,6 +589,20 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("boolean") .HasColumnName("is_live"); + b.Property("LanguageCode") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("language_code"); + + b.Property("LastModified") + .HasColumnType("timestamp without time zone") + .HasColumnName("last_modified"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("last_modified_by"); + b.Property("LockoutEnabled") .HasColumnType("boolean") .HasColumnName("lockout_enabled"); @@ -596,7 +637,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ProfilePictureDataUrl") .HasMaxLength(450) - .HasColumnType("text") + .HasColumnType("character varying(450)") .HasColumnName("profile_picture_data_url"); b.Property("Provider") @@ -628,6 +669,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("character varying(450)") .HasColumnName("tenant_id"); + b.Property("TimeZoneId") + .HasMaxLength(450) + .HasColumnType("character varying(450)") + .HasColumnName("time_zone_id"); + b.Property("TwoFactorEnabled") .HasColumnType("boolean") .HasColumnName("two_factor_enabled"); diff --git a/src/Migrators/Migrators.SqLite/Migrations/20241007113815_TimeZoneId_LanguageCode.Designer.cs b/src/Migrators/Migrators.SqLite/Migrations/20241007113815_TimeZoneId_LanguageCode.Designer.cs new file mode 100644 index 000000000..0395f9850 --- /dev/null +++ b/src/Migrators/Migrators.SqLite/Migrations/20241007113815_TimeZoneId_LanguageCode.Designer.cs @@ -0,0 +1,810 @@ +// +using System; +using CleanArchitecture.Blazor.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CleanArchitecture.Blazor.Migrators.SqLite.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20241007113815_TimeZoneId_LanguageCode")] + partial class TimeZoneId_LanguageCode + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.8"); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.AuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AffectedColumns") + .HasColumnType("TEXT"); + + b.Property("AuditType") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DateTime") + .HasColumnType("TEXT"); + + b.Property("NewValues") + .HasColumnType("TEXT"); + + b.Property("OldValues") + .HasColumnType("TEXT"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("TableName") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AuditTrails"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Contact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Country") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Contacts"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Content") + .HasMaxLength(4000) + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("DocumentType") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("IsPublic") + .HasColumnType("INTEGER"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("INTEGER"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Title") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("URL") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("LastModifiedBy"); + + b.HasIndex("TenantId"); + + b.ToTable("Documents"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Logger", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClientAgent") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("ClientIP") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Exception") + .HasMaxLength(2147483647) + .HasColumnType("TEXT"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("LogEvent") + .HasMaxLength(2147483647) + .HasColumnType("TEXT"); + + b.Property("Message") + .HasMaxLength(2147483647) + .HasColumnType("TEXT"); + + b.Property("MessageTemplate") + .HasMaxLength(2147483647) + .HasColumnType("TEXT"); + + b.Property("Properties") + .HasMaxLength(2147483647) + .HasColumnType("TEXT"); + + b.Property("TimeStamp") + .HasColumnType("TEXT"); + + b.Property("UserName") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("TimeStamp"); + + b.ToTable("Loggers"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.PicklistSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Text") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Value") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Value") + .IsUnique(); + + b.ToTable("PicklistSets"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Brand") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("TEXT"); + + b.Property("Pictures") + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("TEXT"); + + b.Property("Unit") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Tenant", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Tenants"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.HasIndex("TenantId"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("RoleId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .HasColumnType("INTEGER"); + + b.Property("IsLive") + .HasColumnType("INTEGER"); + + b.Property("LanguageCode") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("ProfilePictureDataUrl") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Provider") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("RefreshToken") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("RefreshTokenExpiryTime") + .HasColumnType("TEXT"); + + b.Property("SecurityStamp") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("SuperiorId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("TenantId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("TimeZoneId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.HasIndex("SuperiorId"); + + b.HasIndex("TenantId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserLogin", b => + { + b.Property("LoginProvider") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserRole", b => + { + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserToken", b => + { + b.Property("UserId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Value") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FriendlyName") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("Xml") + .HasMaxLength(4000) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.AuditTrail", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Document", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "LastModifier") + .WithMany() + .HasForeignKey("LastModifiedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("LastModifier"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRoleClaim", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", "Role") + .WithMany("RoleClaims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Superior") + .WithMany() + .HasForeignKey("SuperiorId"); + + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Superior"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserClaim", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserLogin", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserRole", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserToken", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.Navigation("RoleClaims"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.Navigation("Logins"); + + b.Navigation("Tokens"); + + b.Navigation("UserClaims"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrators/Migrators.SqLite/Migrations/20241007113815_TimeZoneId_LanguageCode.cs b/src/Migrators/Migrators.SqLite/Migrations/20241007113815_TimeZoneId_LanguageCode.cs new file mode 100644 index 000000000..d47b3e882 --- /dev/null +++ b/src/Migrators/Migrators.SqLite/Migrations/20241007113815_TimeZoneId_LanguageCode.cs @@ -0,0 +1,147 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CleanArchitecture.Blazor.Migrators.SqLite.Migrations +{ + /// + public partial class TimeZoneId_LanguageCode : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ProfilePictureDataUrl", + table: "AspNetUsers", + type: "TEXT", + maxLength: 450, + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldMaxLength: 450, + oldNullable: true); + + migrationBuilder.AddColumn( + name: "Created", + table: "AspNetUsers", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "CreatedBy", + table: "AspNetUsers", + type: "TEXT", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "LanguageCode", + table: "AspNetUsers", + type: "TEXT", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModified", + table: "AspNetUsers", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModifiedBy", + table: "AspNetUsers", + type: "TEXT", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "TimeZoneId", + table: "AspNetUsers", + type: "TEXT", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "Created", + table: "AspNetRoles", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "CreatedBy", + table: "AspNetRoles", + type: "TEXT", + maxLength: 450, + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModified", + table: "AspNetRoles", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModifiedBy", + table: "AspNetRoles", + type: "TEXT", + maxLength: 450, + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Created", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "CreatedBy", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "LanguageCode", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "LastModified", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "LastModifiedBy", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "TimeZoneId", + table: "AspNetUsers"); + + migrationBuilder.DropColumn( + name: "Created", + table: "AspNetRoles"); + + migrationBuilder.DropColumn( + name: "CreatedBy", + table: "AspNetRoles"); + + migrationBuilder.DropColumn( + name: "LastModified", + table: "AspNetRoles"); + + migrationBuilder.DropColumn( + name: "LastModifiedBy", + table: "AspNetRoles"); + + migrationBuilder.AlterColumn( + name: "ProfilePictureDataUrl", + table: "AspNetUsers", + type: "text", + maxLength: 450, + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldMaxLength: 450, + oldNullable: true); + } + } +} diff --git a/src/Migrators/Migrators.SqLite/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Migrators/Migrators.SqLite/Migrations/ApplicationDbContextModelSnapshot.cs index 64e1b45e7..f2233b7f7 100644 --- a/src/Migrators/Migrators.SqLite/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Migrators/Migrators.SqLite/Migrations/ApplicationDbContextModelSnapshot.cs @@ -346,10 +346,24 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(450) .HasColumnType("TEXT"); + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + b.Property("Description") .HasMaxLength(450) .HasColumnType("TEXT"); + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + b.Property("Name") .HasMaxLength(256) .HasColumnType("TEXT"); @@ -421,6 +435,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(450) .HasColumnType("TEXT"); + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + b.Property("DisplayName") .HasMaxLength(450) .HasColumnType("TEXT"); @@ -438,6 +459,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IsLive") .HasColumnType("INTEGER"); + b.Property("LanguageCode") + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedBy") + .HasMaxLength(450) + .HasColumnType("TEXT"); + b.Property("LockoutEnabled") .HasColumnType("INTEGER"); @@ -465,7 +497,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ProfilePictureDataUrl") .HasMaxLength(450) - .HasColumnType("text"); + .HasColumnType("TEXT"); b.Property("Provider") .HasMaxLength(450) @@ -490,6 +522,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(450) .HasColumnType("TEXT"); + b.Property("TimeZoneId") + .HasMaxLength(450) + .HasColumnType("TEXT"); + b.Property("TwoFactorEnabled") .HasColumnType("INTEGER"); diff --git a/src/Server.UI/appsettings.json b/src/Server.UI/appsettings.json index c5bbc2f3a..8dffd5b1f 100644 --- a/src/Server.UI/appsettings.json +++ b/src/Server.UI/appsettings.json @@ -3,8 +3,8 @@ "DatabaseSettings": { //"DBProvider": "sqlite", //"ConnectionString": "Data Source=BlazorDashboardDb.db" - "DBProvider": "mssql", - "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=BlazorDashboardDb;Trusted_Connection=True;MultipleActiveResultSets=true;" + //"DBProvider": "mssql", + //"ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=BlazorDashboardDb;Trusted_Connection=True;MultipleActiveResultSets=true;" //"DBProvider": "postgresql", //"ConnectionString": "Server=127.0.0.1;Database=BlazorDashboardDb;User Id=root;Password=root;Port=5432" }, From 59fe6d1dee9b1af20cf9f591d933dd7044dc6c5d Mon Sep 17 00:00:00 2001 From: "hualin.zhu" Date: Mon, 7 Oct 2024 19:58:49 +0800 Subject: [PATCH 04/14] LanguageAutocomplete ,TimeZoneAutocomplete --- .../Autocompletes/LanguageAutocomplete.cs | 41 +++++++++++++++++++ .../Autocompletes/TimeZoneAutocomplete.cs | 34 +++++++++++++++ src/Server.UI/appsettings.json | 4 +- 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/Server.UI/Components/Autocompletes/LanguageAutocomplete.cs create mode 100644 src/Server.UI/Components/Autocompletes/TimeZoneAutocomplete.cs diff --git a/src/Server.UI/Components/Autocompletes/LanguageAutocomplete.cs b/src/Server.UI/Components/Autocompletes/LanguageAutocomplete.cs new file mode 100644 index 000000000..39bb17410 --- /dev/null +++ b/src/Server.UI/Components/Autocompletes/LanguageAutocomplete.cs @@ -0,0 +1,41 @@ +using System.Globalization; +using CleanArchitecture.Blazor.Application.Features.PicklistSets.DTOs; + +namespace CleanArchitecture.Blazor.Server.UI.Components.Autocompletes; + +public class LanguageAutocomplete : MudAutocomplete +{ + private List Languages { get; set; }= CultureInfo.GetCultures(CultureTypes.SpecificCultures).ToList(); + + + + public LanguageAutocomplete() + { + + SearchFunc = SearchFunc_; + Clearable = true; + Dense = true; + ResetValueOnEmptyText = true; + ToStringFunc = x => + { + var language = Languages.FirstOrDefault(lang => lang.Name == x); + return language != null ? $"{language.DisplayName} ({language.Name})" : x; + }; + } + + private Task> SearchFunc_(string value, CancellationToken cancellation = default) + { + // 如果输入为空,返回完整的语言列表;否则进行模糊搜索 + return string.IsNullOrEmpty(value) + ? Task.FromResult(Languages.Select(lang => lang.Name).AsEnumerable()) + : Task.FromResult(Languages + .Where(lang => Contains(lang, value)) + .Select(lang => lang.Name)); + } + + private static bool Contains(CultureInfo language, string value) + { + return language.DisplayName.Contains(value, StringComparison.InvariantCultureIgnoreCase) || + language.Name.Contains(value, StringComparison.InvariantCultureIgnoreCase); + } +} diff --git a/src/Server.UI/Components/Autocompletes/TimeZoneAutocomplete.cs b/src/Server.UI/Components/Autocompletes/TimeZoneAutocomplete.cs new file mode 100644 index 000000000..abc52a39e --- /dev/null +++ b/src/Server.UI/Components/Autocompletes/TimeZoneAutocomplete.cs @@ -0,0 +1,34 @@ +using CleanArchitecture.Blazor.Application.Features.PicklistSets.DTOs; + +namespace CleanArchitecture.Blazor.Server.UI.Components.Autocompletes; + +public class TimeZoneAutocomplete : MudAutocomplete +{ + private List TimeZones { get; set; }= TimeZoneInfo.GetSystemTimeZones().ToList(); + public TimeZoneAutocomplete() + { + SearchFunc = SearchFunc_; + Dense = true; + ResetValueOnEmptyText = true; + ToStringFunc = x => + { + var timeZone = TimeZones.FirstOrDefault(tz => tz.Id == x); + return timeZone != null ? timeZone.DisplayName : x; + }; + } + + private Task> SearchFunc_(string value, CancellationToken cancellation = default) + { + return string.IsNullOrEmpty(value) + ? Task.FromResult(TimeZones.Select(tz => tz.Id).AsEnumerable()) + : Task.FromResult(TimeZones + .Where(tz => Contains(tz, value)) + .Select(tz => tz.Id)); + } + + private static bool Contains(TimeZoneInfo timeZone, string value) + { + return timeZone.DisplayName.Contains(value, StringComparison.InvariantCultureIgnoreCase) || + timeZone.Id.Contains(value, StringComparison.InvariantCultureIgnoreCase); + } +} \ No newline at end of file diff --git a/src/Server.UI/appsettings.json b/src/Server.UI/appsettings.json index 8dffd5b1f..c5bbc2f3a 100644 --- a/src/Server.UI/appsettings.json +++ b/src/Server.UI/appsettings.json @@ -3,8 +3,8 @@ "DatabaseSettings": { //"DBProvider": "sqlite", //"ConnectionString": "Data Source=BlazorDashboardDb.db" - //"DBProvider": "mssql", - //"ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=BlazorDashboardDb;Trusted_Connection=True;MultipleActiveResultSets=true;" + "DBProvider": "mssql", + "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=BlazorDashboardDb;Trusted_Connection=True;MultipleActiveResultSets=true;" //"DBProvider": "postgresql", //"ConnectionString": "Server=127.0.0.1;Database=BlazorDashboardDb;User Id=root;Password=root;Port=5432" }, From 337ebf77808902daf0d296764eceda476b71a11e Mon Sep 17 00:00:00 2001 From: hualin Date: Tue, 8 Oct 2024 10:06:46 +0800 Subject: [PATCH 05/14] commit --- .../Components/Autocompletes/LanguageAutocomplete.cs | 9 ++------- .../Components/Autocompletes/TimeZoneAutocomplete.cs | 6 ++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Server.UI/Components/Autocompletes/LanguageAutocomplete.cs b/src/Server.UI/Components/Autocompletes/LanguageAutocomplete.cs index 39bb17410..be21a2708 100644 --- a/src/Server.UI/Components/Autocompletes/LanguageAutocomplete.cs +++ b/src/Server.UI/Components/Autocompletes/LanguageAutocomplete.cs @@ -1,24 +1,19 @@ using System.Globalization; -using CleanArchitecture.Blazor.Application.Features.PicklistSets.DTOs; namespace CleanArchitecture.Blazor.Server.UI.Components.Autocompletes; public class LanguageAutocomplete : MudAutocomplete { private List Languages { get; set; }= CultureInfo.GetCultures(CultureTypes.SpecificCultures).ToList(); - - - - public LanguageAutocomplete() + public LanguageAutocomplete() { - SearchFunc = SearchFunc_; Clearable = true; Dense = true; ResetValueOnEmptyText = true; ToStringFunc = x => { - var language = Languages.FirstOrDefault(lang => lang.Name == x); + var language = Languages.FirstOrDefault(lang => lang.Name.Equals(x)); return language != null ? $"{language.DisplayName} ({language.Name})" : x; }; } diff --git a/src/Server.UI/Components/Autocompletes/TimeZoneAutocomplete.cs b/src/Server.UI/Components/Autocompletes/TimeZoneAutocomplete.cs index abc52a39e..b09bbbfd8 100644 --- a/src/Server.UI/Components/Autocompletes/TimeZoneAutocomplete.cs +++ b/src/Server.UI/Components/Autocompletes/TimeZoneAutocomplete.cs @@ -1,6 +1,4 @@ -using CleanArchitecture.Blazor.Application.Features.PicklistSets.DTOs; - -namespace CleanArchitecture.Blazor.Server.UI.Components.Autocompletes; +namespace CleanArchitecture.Blazor.Server.UI.Components.Autocompletes; public class TimeZoneAutocomplete : MudAutocomplete { @@ -12,7 +10,7 @@ public TimeZoneAutocomplete() ResetValueOnEmptyText = true; ToStringFunc = x => { - var timeZone = TimeZones.FirstOrDefault(tz => tz.Id == x); + var timeZone = TimeZones.FirstOrDefault(tz => tz.Id.Equals(x)); return timeZone != null ? timeZone.DisplayName : x; }; } From 92e782b9b5918751ecaabbbe1fb8b0fe08d2538d Mon Sep 17 00:00:00 2001 From: hualin Date: Tue, 8 Oct 2024 11:03:40 +0800 Subject: [PATCH 06/14] add input field for Language TimeZoneId --- .../Common/Security/ChangeUserProfileModel.cs | 3 +- .../MultiTenantAutocomplete.razor.cs | 1 - .../Authentication/ExternalLogin.razor | 53 ++++++++++++++++++ .../Identity/Authentication/Register.razor | 56 ++++++++++++++++++- .../Identity/Users/Components/UserForm.razor | 30 +++++----- .../Pages/Identity/Users/Profile.razor | 8 +++ .../Pages/Identity/Users/Users.razor | 23 ++++++-- 7 files changed, 151 insertions(+), 23 deletions(-) diff --git a/src/Application/Common/Security/ChangeUserProfileModel.cs b/src/Application/Common/Security/ChangeUserProfileModel.cs index 7b0bf260e..9372d7aa2 100644 --- a/src/Application/Common/Security/ChangeUserProfileModel.cs +++ b/src/Application/Common/Security/ChangeUserProfileModel.cs @@ -24,7 +24,8 @@ public class ChangeUserProfileModel public bool IsActive { get; set; } public string? TenantId { get; set; } public string? TenantName { get; set; } - + public string? TimeZoneId { get; set; } + public string? LanguageCode { get; set; } private class Mapping : Profile { public Mapping() diff --git a/src/Server.UI/Components/Autocompletes/MultiTenantAutocomplete.razor.cs b/src/Server.UI/Components/Autocompletes/MultiTenantAutocomplete.razor.cs index 432053fe4..8e3ea55a9 100644 --- a/src/Server.UI/Components/Autocompletes/MultiTenantAutocomplete.razor.cs +++ b/src/Server.UI/Components/Autocompletes/MultiTenantAutocomplete.razor.cs @@ -12,7 +12,6 @@ public MultiTenantAutocomplete() { SearchFunc = SearchKeyValues; ToStringFunc = dto => dto?.Name; - Clearable = true; Dense = true; ResetValueOnEmptyText = true; ShowProgressIndicator = true; diff --git a/src/Server.UI/Pages/Identity/Authentication/ExternalLogin.razor b/src/Server.UI/Pages/Identity/Authentication/ExternalLogin.razor index db6d40847..2c6020096 100644 --- a/src/Server.UI/Pages/Identity/Authentication/ExternalLogin.razor +++ b/src/Server.UI/Pages/Identity/Authentication/ExternalLogin.razor @@ -7,6 +7,7 @@ @using Microsoft.AspNetCore.WebUtilities @using CleanArchitecture.Blazor.Application.Features.Identity.Notifications.UserActivation @using System.ComponentModel.DataAnnotations +@using System.Globalization @inject SignInManager SignInManager @inject UserManager UserManager @@ -66,6 +67,52 @@ +
+
+
+ + @foreach (var item in TimeZoneInfo.GetSystemTimeZones().ToList()) + { + + } + +
+
+ +
+
+
+ +
+
+
+
+
+
+ + @foreach (var item in CultureInfo.GetCultures(CultureTypes.SpecificCultures).ToList()) + { + + } + +
+
+ +
+
+
+ +
+
+
UserManager @inject IStringLocalizer L @@ -33,7 +34,7 @@ width:100%; appearance: none; background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAxNiAxNic+PHBhdGggZmlsbD0nbm9uZScgc3Ryb2tlPScjMzQzYTQwJyBzdHJva2UtbGluZWNhcD0ncm91bmQnIHN0cm9rZS1saW5lam9pbj0ncm91bmQnIHN0cm9rZS13aWR0aD0nMicgZD0nTTIgNWw2IDYgNi02Jy8+PC9zdmc+') no-repeat right 10px center; - background-size: 10px;" aria-required="true"> + background-size: 10px;" aria-required="true"> @foreach (var tenant in TenantsService.DataSource) { @@ -124,7 +125,52 @@ - +
+
+
+ + @foreach (var item in TimeZoneInfo.GetSystemTimeZones().ToList()) + { + + } + +
+
+ +
+
+
+ +
+
+
+
+
+
+ + @foreach (var item in CultureInfo.GetCultures(CultureTypes.SpecificCultures).ToList()) + { + + } + +
+
+ +
+
+
+ +
+
+