From 7570908177eb0f52e1e0d60a1859a591e747951d Mon Sep 17 00:00:00 2001 From: ivanszabo Date: Wed, 5 Feb 2025 13:48:06 +0100 Subject: [PATCH] Entities + Migration --- src/WorkFlowCheck.API/appsettings.json | 2 +- src/WorkFlowCheck.DL/AppDbContext.cs | 40 +- .../Entities/CheckListTemplateRow.cs | 10 +- .../20250204120742_InitialCreate.Designer.cs | 477 ++++++++++++++++++ .../20250204120742_InitialCreate.cs | 297 +++++++++++ .../Migrations/AppDbContextModelSnapshot.cs | 474 +++++++++++++++++ 6 files changed, 1293 insertions(+), 7 deletions(-) create mode 100644 src/WorkFlowCheck.DL/Migrations/20250204120742_InitialCreate.Designer.cs create mode 100644 src/WorkFlowCheck.DL/Migrations/20250204120742_InitialCreate.cs create mode 100644 src/WorkFlowCheck.DL/Migrations/AppDbContextModelSnapshot.cs diff --git a/src/WorkFlowCheck.API/appsettings.json b/src/WorkFlowCheck.API/appsettings.json index db481fd..7f24213 100644 --- a/src/WorkFlowCheck.API/appsettings.json +++ b/src/WorkFlowCheck.API/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "Data Source=WS2016DC\\SQLEXPRESS;Initial Catalog=WFC;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False" + "DefaultConnection": "Data Source=WS2016DC\\SQLEXPRESS;Initial Catalog=WFCUAT;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False" }, "ApiKey": "RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU=", "Logging": { diff --git a/src/WorkFlowCheck.DL/AppDbContext.cs b/src/WorkFlowCheck.DL/AppDbContext.cs index d22d1fc..a61fc8d 100644 --- a/src/WorkFlowCheck.DL/AppDbContext.cs +++ b/src/WorkFlowCheck.DL/AppDbContext.cs @@ -6,7 +6,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using WorkFlowCheck.Common.RequestContext; +using WorkFlowCheck.Common.Security; using WorkFlowCheck.DL.Configurations; +using WorkFlowCheck.DL.Entities; using WorkFlowCheck.DL.Extensions; using WorkFlowCheck.DL.Interfaces; @@ -55,8 +57,10 @@ namespace WorkFlowCheck.DL modelBuilder.ApplyConfiguration(new RoleTypeConfiguration()); modelBuilder.ApplyConfiguration(new UsersCheckListTemplateHeaderTypeConfiguration()); modelBuilder.ApplyConfiguration(new UserTypeConfiguration()); - + modelBuilder.RegisterSoftDeleteQueryFilters(); + + SeedInit(modelBuilder); } public override async Task SaveChangesAsync(CancellationToken cancellationToken = default) { @@ -111,5 +115,39 @@ namespace WorkFlowCheck.DL entry.State = EntityState.Modified; } } + + private void SeedInit(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasData( + new User + { + Id = 1, + Email = "admin@nuvolar.hu", + FirstName = "Administrator", + LastName = "System", + IsDeleted = false, + UserName = "admin", + PasswordHash = PasswordHasher.HashPassword("111111"), + CreatedAt = DateTime.UtcNow, + CreatedBy = "System", + LastModAt = DateTime.UtcNow, + LastModBy = "System", + }, + new User + { + Id = 2, + Email = "user@nuvolar.hu", + FirstName = "User", + LastName = "System", + IsDeleted = false, + UserName = "user", + PasswordHash = PasswordHasher.HashPassword("222222"), + CreatedAt = DateTime.UtcNow, + CreatedBy = "System", + LastModAt = DateTime.UtcNow, + LastModBy = "System", + } + ); + } } } diff --git a/src/WorkFlowCheck.DL/Entities/CheckListTemplateRow.cs b/src/WorkFlowCheck.DL/Entities/CheckListTemplateRow.cs index 2a106ee..09adafc 100644 --- a/src/WorkFlowCheck.DL/Entities/CheckListTemplateRow.cs +++ b/src/WorkFlowCheck.DL/Entities/CheckListTemplateRow.cs @@ -12,12 +12,12 @@ namespace WorkFlowCheck.DL.Entities public int Id { get; set; } public int RowIndex { get; set; } public int CheckListTemplateHeaderId { get; set; } - public virtual CheckListTemplateHeader CheckListTemplateHeader { get; set; } - public int EquipmentId { get; set; } + public virtual CheckListTemplateHeader CheckListTemplateHeader { get; set; } + public int EquipmentId { get; set; } public virtual Equipment Equipment { get; set; } - public int CheckPointId { get; set; } - public virtual CheckPoint EquipmentPoint { get; set; } - public string OperationDescription { get; set; } + public int CheckPointId { get; set; } + public virtual CheckPoint CheckPoint { get; set; } + public string OperationDescription { get; set; } = null!; public bool IsDeleted { get; set; } public DateTime LastModAt { get; set; } diff --git a/src/WorkFlowCheck.DL/Migrations/20250204120742_InitialCreate.Designer.cs b/src/WorkFlowCheck.DL/Migrations/20250204120742_InitialCreate.Designer.cs new file mode 100644 index 0000000..27df82a --- /dev/null +++ b/src/WorkFlowCheck.DL/Migrations/20250204120742_InitialCreate.Designer.cs @@ -0,0 +1,477 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WorkFlowCheck.DL; + +#nullable disable + +namespace WorkFlowCheck.DL.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20250204120742_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.12") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListHeader", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DocumentNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsStorno") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("CheckListHeader", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("CheckListTemplateHeader", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListTemplateRow", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CheckListHeaderId") + .HasColumnType("int"); + + b.Property("CheckListTemplateHeaderId") + .HasColumnType("int"); + + b.Property("CheckPointId") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperationDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RowIndex") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CheckListHeaderId"); + + b.HasIndex("CheckListTemplateHeaderId"); + + b.HasIndex("CheckPointId"); + + b.HasIndex("EquipmentId"); + + b.ToTable("CheckListTemplateRow", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckPoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("CheckPoint", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.Equipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EquipmentNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Equipment", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Location", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Users", (string)null); + + b.HasData( + new + { + Id = 1, + CreatedAt = new DateTime(2025, 2, 4, 12, 7, 41, 52, DateTimeKind.Utc).AddTicks(7796), + CreatedBy = "System", + Email = "admin@nuvolar.hu", + FirstName = "Administrator", + IsDeleted = false, + LastModAt = new DateTime(2025, 2, 4, 12, 7, 41, 52, DateTimeKind.Utc).AddTicks(7803), + LastModBy = "System", + LastName = "System", + PasswordHash = "eGM0NUREZnJ0ISFFRDIxMKE5TYwthDBuUsTUEO1fBnCR3VdSCmdz47ue0RoVvnkY", + UserName = "admin" + }, + new + { + Id = 2, + CreatedAt = new DateTime(2025, 2, 4, 12, 7, 41, 64, DateTimeKind.Utc).AddTicks(4114), + CreatedBy = "System", + Email = "user@nuvolar.hu", + FirstName = "User", + IsDeleted = false, + LastModAt = new DateTime(2025, 2, 4, 12, 7, 41, 64, DateTimeKind.Utc).AddTicks(4117), + LastModBy = "System", + LastName = "System", + PasswordHash = "eGM0NUREZnJ0ISFFRDIxMPwM2D9sQSj7zmaSBIsOGe0I9hBFwCGPVbyrYMA5EnKG", + UserName = "user" + }); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.UsersCheckListTemplateHeader", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CheckListTemplateHeaderId") + .HasColumnType("int"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("UsersId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CheckListTemplateHeaderId"); + + b.HasIndex("UserId"); + + b.ToTable("UsersCheckListTemplateHeader", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListTemplateRow", b => + { + b.HasOne("WorkFlowCheck.DL.Entities.CheckListHeader", null) + .WithMany("CheckListTemplateRows") + .HasForeignKey("CheckListHeaderId"); + + b.HasOne("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", "CheckListTemplateHeader") + .WithMany() + .HasForeignKey("CheckListTemplateHeaderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WorkFlowCheck.DL.Entities.CheckPoint", "EquipmentPoint") + .WithMany() + .HasForeignKey("CheckPointId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WorkFlowCheck.DL.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CheckListTemplateHeader"); + + b.Navigation("Equipment"); + + b.Navigation("EquipmentPoint"); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.UsersCheckListTemplateHeader", b => + { + b.HasOne("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", "CheckListTemplateHeader") + .WithMany() + .HasForeignKey("CheckListTemplateHeaderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WorkFlowCheck.DL.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CheckListTemplateHeader"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListHeader", b => + { + b.Navigation("CheckListTemplateRows"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/WorkFlowCheck.DL/Migrations/20250204120742_InitialCreate.cs b/src/WorkFlowCheck.DL/Migrations/20250204120742_InitialCreate.cs new file mode 100644 index 0000000..79a2bcf --- /dev/null +++ b/src/WorkFlowCheck.DL/Migrations/20250204120742_InitialCreate.cs @@ -0,0 +1,297 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace WorkFlowCheck.DL.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "CheckListHeader", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ShortName = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + DocumentNumber = table.Column(type: "nvarchar(max)", nullable: false), + IsStorno = table.Column(type: "bit", nullable: false), + LastModAt = table.Column(type: "datetime2", nullable: false), + LastModBy = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CheckListHeader", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CheckListTemplateHeader", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ShortName = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModAt = table.Column(type: "datetime2", nullable: false), + LastModBy = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CheckListTemplateHeader", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CheckPoint", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ShortName = table.Column(type: "nvarchar(max)", nullable: false), + Code = table.Column(type: "nvarchar(max)", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModAt = table.Column(type: "datetime2", nullable: false), + LastModBy = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CheckPoint", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Equipment", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ShortName = table.Column(type: "nvarchar(max)", nullable: false), + EquipmentNumber = table.Column(type: "nvarchar(max)", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModAt = table.Column(type: "datetime2", nullable: false), + LastModBy = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Equipment", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Location", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FullName = table.Column(type: "nvarchar(max)", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModAt = table.Column(type: "datetime2", nullable: false), + LastModBy = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Location", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Roles", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RoleName = table.Column(type: "nvarchar(max)", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModAt = table.Column(type: "datetime2", nullable: false), + LastModBy = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Roles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Email = table.Column(type: "nvarchar(max)", nullable: false), + FirstName = table.Column(type: "nvarchar(max)", nullable: false), + LastName = table.Column(type: "nvarchar(max)", nullable: false), + UserName = table.Column(type: "nvarchar(max)", nullable: false), + PasswordHash = table.Column(type: "nvarchar(max)", nullable: true), + LastModAt = table.Column(type: "datetime2", nullable: false), + LastModBy = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CheckListTemplateRow", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RowIndex = table.Column(type: "int", nullable: false), + CheckListTemplateHeaderId = table.Column(type: "int", nullable: false), + EquipmentId = table.Column(type: "int", nullable: false), + CheckPointId = table.Column(type: "int", nullable: false), + OperationDescription = table.Column(type: "nvarchar(max)", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + LastModAt = table.Column(type: "datetime2", nullable: false), + LastModBy = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(max)", nullable: false), + CheckListHeaderId = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CheckListTemplateRow", x => x.Id); + table.ForeignKey( + name: "FK_CheckListTemplateRow_CheckListHeader_CheckListHeaderId", + column: x => x.CheckListHeaderId, + principalTable: "CheckListHeader", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_CheckListTemplateRow_CheckListTemplateHeader_CheckListTemplateHeaderId", + column: x => x.CheckListTemplateHeaderId, + principalTable: "CheckListTemplateHeader", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CheckListTemplateRow_CheckPoint_CheckPointId", + column: x => x.CheckPointId, + principalTable: "CheckPoint", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CheckListTemplateRow_Equipment_EquipmentId", + column: x => x.EquipmentId, + principalTable: "Equipment", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UsersCheckListTemplateHeader", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UsersId = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "int", nullable: false), + CheckListTemplateHeaderId = table.Column(type: "int", nullable: false), + Enabled = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UsersCheckListTemplateHeader", x => x.Id); + table.ForeignKey( + name: "FK_UsersCheckListTemplateHeader_CheckListTemplateHeader_CheckListTemplateHeaderId", + column: x => x.CheckListTemplateHeaderId, + principalTable: "CheckListTemplateHeader", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_UsersCheckListTemplateHeader_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + table: "Users", + columns: new[] { "Id", "CreatedAt", "CreatedBy", "Email", "FirstName", "IsDeleted", "LastModAt", "LastModBy", "LastName", "PasswordHash", "UserName" }, + values: new object[,] + { + { 1, new DateTime(2025, 2, 4, 12, 7, 41, 52, DateTimeKind.Utc).AddTicks(7796), "System", "admin@nuvolar.hu", "Administrator", false, new DateTime(2025, 2, 4, 12, 7, 41, 52, DateTimeKind.Utc).AddTicks(7803), "System", "System", "eGM0NUREZnJ0ISFFRDIxMKE5TYwthDBuUsTUEO1fBnCR3VdSCmdz47ue0RoVvnkY", "admin" }, + { 2, new DateTime(2025, 2, 4, 12, 7, 41, 64, DateTimeKind.Utc).AddTicks(4114), "System", "user@nuvolar.hu", "User", false, new DateTime(2025, 2, 4, 12, 7, 41, 64, DateTimeKind.Utc).AddTicks(4117), "System", "System", "eGM0NUREZnJ0ISFFRDIxMPwM2D9sQSj7zmaSBIsOGe0I9hBFwCGPVbyrYMA5EnKG", "user" } + }); + + migrationBuilder.CreateIndex( + name: "IX_CheckListTemplateRow_CheckListHeaderId", + table: "CheckListTemplateRow", + column: "CheckListHeaderId"); + + migrationBuilder.CreateIndex( + name: "IX_CheckListTemplateRow_CheckListTemplateHeaderId", + table: "CheckListTemplateRow", + column: "CheckListTemplateHeaderId"); + + migrationBuilder.CreateIndex( + name: "IX_CheckListTemplateRow_CheckPointId", + table: "CheckListTemplateRow", + column: "CheckPointId"); + + migrationBuilder.CreateIndex( + name: "IX_CheckListTemplateRow_EquipmentId", + table: "CheckListTemplateRow", + column: "EquipmentId"); + + migrationBuilder.CreateIndex( + name: "IX_UsersCheckListTemplateHeader_CheckListTemplateHeaderId", + table: "UsersCheckListTemplateHeader", + column: "CheckListTemplateHeaderId"); + + migrationBuilder.CreateIndex( + name: "IX_UsersCheckListTemplateHeader_UserId", + table: "UsersCheckListTemplateHeader", + column: "UserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CheckListTemplateRow"); + + migrationBuilder.DropTable( + name: "Location"); + + migrationBuilder.DropTable( + name: "Roles"); + + migrationBuilder.DropTable( + name: "UsersCheckListTemplateHeader"); + + migrationBuilder.DropTable( + name: "CheckListHeader"); + + migrationBuilder.DropTable( + name: "CheckPoint"); + + migrationBuilder.DropTable( + name: "Equipment"); + + migrationBuilder.DropTable( + name: "CheckListTemplateHeader"); + + migrationBuilder.DropTable( + name: "Users"); + } + } +} diff --git a/src/WorkFlowCheck.DL/Migrations/AppDbContextModelSnapshot.cs b/src/WorkFlowCheck.DL/Migrations/AppDbContextModelSnapshot.cs new file mode 100644 index 0000000..fde7339 --- /dev/null +++ b/src/WorkFlowCheck.DL/Migrations/AppDbContextModelSnapshot.cs @@ -0,0 +1,474 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WorkFlowCheck.DL; + +#nullable disable + +namespace WorkFlowCheck.DL.Migrations +{ + [DbContext(typeof(AppDbContext))] + partial class AppDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.12") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListHeader", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DocumentNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsStorno") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("CheckListHeader", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("CheckListTemplateHeader", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListTemplateRow", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CheckListHeaderId") + .HasColumnType("int"); + + b.Property("CheckListTemplateHeaderId") + .HasColumnType("int"); + + b.Property("CheckPointId") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperationDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RowIndex") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CheckListHeaderId"); + + b.HasIndex("CheckListTemplateHeaderId"); + + b.HasIndex("CheckPointId"); + + b.HasIndex("EquipmentId"); + + b.ToTable("CheckListTemplateRow", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckPoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("CheckPoint", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.Equipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EquipmentNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Equipment", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Location", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Users", (string)null); + + b.HasData( + new + { + Id = 1, + CreatedAt = new DateTime(2025, 2, 4, 12, 7, 41, 52, DateTimeKind.Utc).AddTicks(7796), + CreatedBy = "System", + Email = "admin@nuvolar.hu", + FirstName = "Administrator", + IsDeleted = false, + LastModAt = new DateTime(2025, 2, 4, 12, 7, 41, 52, DateTimeKind.Utc).AddTicks(7803), + LastModBy = "System", + LastName = "System", + PasswordHash = "eGM0NUREZnJ0ISFFRDIxMKE5TYwthDBuUsTUEO1fBnCR3VdSCmdz47ue0RoVvnkY", + UserName = "admin" + }, + new + { + Id = 2, + CreatedAt = new DateTime(2025, 2, 4, 12, 7, 41, 64, DateTimeKind.Utc).AddTicks(4114), + CreatedBy = "System", + Email = "user@nuvolar.hu", + FirstName = "User", + IsDeleted = false, + LastModAt = new DateTime(2025, 2, 4, 12, 7, 41, 64, DateTimeKind.Utc).AddTicks(4117), + LastModBy = "System", + LastName = "System", + PasswordHash = "eGM0NUREZnJ0ISFFRDIxMPwM2D9sQSj7zmaSBIsOGe0I9hBFwCGPVbyrYMA5EnKG", + UserName = "user" + }); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.UsersCheckListTemplateHeader", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CheckListTemplateHeaderId") + .HasColumnType("int"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("UsersId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CheckListTemplateHeaderId"); + + b.HasIndex("UserId"); + + b.ToTable("UsersCheckListTemplateHeader", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListTemplateRow", b => + { + b.HasOne("WorkFlowCheck.DL.Entities.CheckListHeader", null) + .WithMany("CheckListTemplateRows") + .HasForeignKey("CheckListHeaderId"); + + b.HasOne("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", "CheckListTemplateHeader") + .WithMany() + .HasForeignKey("CheckListTemplateHeaderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WorkFlowCheck.DL.Entities.CheckPoint", "EquipmentPoint") + .WithMany() + .HasForeignKey("CheckPointId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WorkFlowCheck.DL.Entities.Equipment", "Equipment") + .WithMany() + .HasForeignKey("EquipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CheckListTemplateHeader"); + + b.Navigation("Equipment"); + + b.Navigation("EquipmentPoint"); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.UsersCheckListTemplateHeader", b => + { + b.HasOne("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", "CheckListTemplateHeader") + .WithMany() + .HasForeignKey("CheckListTemplateHeaderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WorkFlowCheck.DL.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CheckListTemplateHeader"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListHeader", b => + { + b.Navigation("CheckListTemplateRows"); + }); +#pragma warning restore 612, 618 + } + } +}