diff --git a/CleanArchitecture.Domain/Entities/User.cs b/CleanArchitecture.Domain/Entities/User.cs index 4d9ddd3..186913e 100644 --- a/CleanArchitecture.Domain/Entities/User.cs +++ b/CleanArchitecture.Domain/Entities/User.cs @@ -9,13 +9,13 @@ public class User : Entity public User( Guid id, string email, - string firstname, + string firstName, string lastName, string password, UserRole role) : base(id) { Email = email; - FirstName = firstname; + FirstName = firstName; LastName = lastName; Password = password; Role = role; diff --git a/CleanArchitecture.Infrastructure/Migrations/20230418111403_RenameUserNames.Designer.cs b/CleanArchitecture.Infrastructure/Migrations/20230418111403_RenameUserNames.Designer.cs new file mode 100644 index 0000000..b9fbe52 --- /dev/null +++ b/CleanArchitecture.Infrastructure/Migrations/20230418111403_RenameUserNames.Designer.cs @@ -0,0 +1,82 @@ +// +using System; +using CleanArchitecture.Infrastructure.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CleanArchitecture.Infrastructure.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20230418111403_RenameUserNames")] + partial class RenameUserNames + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Proxies:ChangeTracking", false) + .HasAnnotation("Proxies:CheckEquality", false) + .HasAnnotation("Proxies:LazyLoading", true) + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CleanArchitecture.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(320) + .HasColumnType("nvarchar(320)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Role") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Users"); + + b.HasData( + new + { + Id = new Guid("28fc3d91-6a15-448e-b0b5-0c91a3948961"), + Deleted = false, + Email = "admin@email.com", + FirstName = "Admin", + LastName = "User", + Password = "$2a$12$Blal/uiFIJdYsCLTMUik/egLbfg3XhbnxBC6Sb5IKz2ZYhiU/MzL2", + Role = 0 + }); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CleanArchitecture.Infrastructure/Migrations/20230418111403_RenameUserNames.cs b/CleanArchitecture.Infrastructure/Migrations/20230418111403_RenameUserNames.cs new file mode 100644 index 0000000..ae477da --- /dev/null +++ b/CleanArchitecture.Infrastructure/Migrations/20230418111403_RenameUserNames.cs @@ -0,0 +1,59 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CleanArchitecture.Infrastructure.Migrations +{ + /// + public partial class RenameUserNames : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DeleteData( + table: "Users", + keyColumn: "Id", + keyValue: new Guid("3fc7aacd-41cc-4ca2-b842-32edcd0782d5")); + + migrationBuilder.RenameColumn( + name: "Surname", + table: "Users", + newName: "LastName"); + + migrationBuilder.RenameColumn( + name: "GivenName", + table: "Users", + newName: "FirstName"); + + migrationBuilder.InsertData( + table: "Users", + columns: new[] { "Id", "Deleted", "Email", "FirstName", "LastName", "Password", "Role" }, + values: new object[] { new Guid("28fc3d91-6a15-448e-b0b5-0c91a3948961"), false, "admin@email.com", "Admin", "User", "$2a$12$Blal/uiFIJdYsCLTMUik/egLbfg3XhbnxBC6Sb5IKz2ZYhiU/MzL2", 0 }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DeleteData( + table: "Users", + keyColumn: "Id", + keyValue: new Guid("28fc3d91-6a15-448e-b0b5-0c91a3948961")); + + migrationBuilder.RenameColumn( + name: "LastName", + table: "Users", + newName: "Surname"); + + migrationBuilder.RenameColumn( + name: "FirstName", + table: "Users", + newName: "GivenName"); + + migrationBuilder.InsertData( + table: "Users", + columns: new[] { "Id", "Deleted", "Email", "GivenName", "Password", "Role", "Surname" }, + values: new object[] { new Guid("3fc7aacd-41cc-4ca2-b842-32edcd0782d5"), false, "admin@email.com", "User", "$2a$12$Blal/uiFIJdYsCLTMUik/egLbfg3XhbnxBC6Sb5IKz2ZYhiU/MzL2", 0, "Admin" }); + } + } +} diff --git a/CleanArchitecture.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs b/CleanArchitecture.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs index 249004e..6a2eca6 100644 --- a/CleanArchitecture.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/CleanArchitecture.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ namespace CleanArchitecture.Infrastructure.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("ProductVersion", "7.0.5") .HasAnnotation("Proxies:ChangeTracking", false) .HasAnnotation("Proxies:CheckEquality", false) .HasAnnotation("Proxies:LazyLoading", true) @@ -39,7 +39,12 @@ namespace CleanArchitecture.Infrastructure.Migrations .HasMaxLength(320) .HasColumnType("nvarchar(320)"); - b.Property("GivenName") + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LastName") .IsRequired() .HasMaxLength(100) .HasColumnType("nvarchar(100)"); @@ -52,11 +57,6 @@ namespace CleanArchitecture.Infrastructure.Migrations b.Property("Role") .HasColumnType("int"); - b.Property("Surname") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - b.HasKey("Id"); b.ToTable("Users"); @@ -64,13 +64,13 @@ namespace CleanArchitecture.Infrastructure.Migrations b.HasData( new { - Id = new Guid("3fc7aacd-41cc-4ca2-b842-32edcd0782d5"), + Id = new Guid("28fc3d91-6a15-448e-b0b5-0c91a3948961"), Deleted = false, Email = "admin@email.com", - GivenName = "User", + FirstName = "Admin", + LastName = "User", Password = "$2a$12$Blal/uiFIJdYsCLTMUik/egLbfg3XhbnxBC6Sb5IKz2ZYhiU/MzL2", - Role = 0, - Surname = "Admin" + Role = 0 }); }); #pragma warning restore 612, 618