diff --git a/Hcs.WebApp/Data/Hcs/Migrations/20251022073558_CreateHcsSchema.Designer.cs b/Hcs.WebApp/Data/Hcs/Migrations/20251022073558_CreateHcsSchema.Designer.cs deleted file mode 100644 index 092737e..0000000 --- a/Hcs.WebApp/Data/Hcs/Migrations/20251022073558_CreateHcsSchema.Designer.cs +++ /dev/null @@ -1,82 +0,0 @@ -// -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable -namespace Hcs.WebApp.Data.Hcs.Migrations -{ - [DbContext(typeof(HcsDbContext))] - [Migration("20251022073558_CreateHcsSchema")] - partial class CreateHcsSchema - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.9") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("Number") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Registries"); - }); - - modelBuilder.Entity("Hcs.WebApp.Data.Hcs.RegistryElement", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("Code") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("GUID") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("RegistryId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Xml") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("RegistryId"); - - b.ToTable("Elements"); - }); - - modelBuilder.Entity("Hcs.WebApp.Data.Hcs.RegistryElement", b => - { - b.HasOne("Hcs.WebApp.Data.Hcs.Registry", "Registry") - .WithMany("Elements") - .HasForeignKey("RegistryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Registry"); - }); - - modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b => - { - b.Navigation("Elements"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Hcs.WebApp/Data/Hcs/Migrations/20251022075934_SpecifyCommonRegistry.Designer.cs b/Hcs.WebApp/Data/Hcs/Migrations/20251022075934_SpecifyCommonRegistry.Designer.cs deleted file mode 100644 index bb7245c..0000000 --- a/Hcs.WebApp/Data/Hcs/Migrations/20251022075934_SpecifyCommonRegistry.Designer.cs +++ /dev/null @@ -1,85 +0,0 @@ -// -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable -namespace Hcs.WebApp.Data.Hcs.Migrations -{ - [DbContext(typeof(HcsDbContext))] - [Migration("20251022075934_SpecifyCommonRegistry")] - partial class SpecifyCommonRegistry - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.9") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("IsCommon") - .HasColumnType("bit"); - - b.Property("Number") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Registries"); - }); - - modelBuilder.Entity("Hcs.WebApp.Data.Hcs.RegistryElement", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("Code") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("GUID") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("RegistryId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Xml") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("RegistryId"); - - b.ToTable("Elements"); - }); - - modelBuilder.Entity("Hcs.WebApp.Data.Hcs.RegistryElement", b => - { - b.HasOne("Hcs.WebApp.Data.Hcs.Registry", "Registry") - .WithMany("Elements") - .HasForeignKey("RegistryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Registry"); - }); - - modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b => - { - b.Navigation("Elements"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Hcs.WebApp/Data/Hcs/Migrations/20251022075934_SpecifyCommonRegistry.cs b/Hcs.WebApp/Data/Hcs/Migrations/20251022075934_SpecifyCommonRegistry.cs deleted file mode 100644 index 547f37b..0000000 --- a/Hcs.WebApp/Data/Hcs/Migrations/20251022075934_SpecifyCommonRegistry.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable -namespace Hcs.WebApp.Data.Hcs.Migrations -{ - /// - public partial class SpecifyCommonRegistry : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IsCommon", - table: "Registries", - type: "bit", - nullable: false, - defaultValue: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IsCommon", - table: "Registries"); - } - } -} diff --git a/Hcs.WebApp/Data/Hcs/Migrations/20251023014411_AddOperation.cs b/Hcs.WebApp/Data/Hcs/Migrations/20251023014411_AddOperation.cs deleted file mode 100644 index a5099f6..0000000 --- a/Hcs.WebApp/Data/Hcs/Migrations/20251023014411_AddOperation.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable -namespace Hcs.WebApp.Data.Hcs.Migrations -{ - /// - public partial class AddOperation : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Name", - table: "Registries", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "UpdatedAt", - table: "Registries", - type: "datetime2", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.CreateTable( - name: "Operations", - columns: table => new - { - Id = table.Column(type: "nvarchar(450)", nullable: false), - Type = table.Column(type: "nvarchar(max)", nullable: false), - InitiatorId = table.Column(type: "nvarchar(max)", nullable: false), - StartedAt = table.Column(type: "datetime2", nullable: false), - EndedAt = table.Column(type: "datetime2", nullable: true), - MessageGuid = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Operations", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Operations"); - - migrationBuilder.DropColumn( - name: "Name", - table: "Registries"); - - migrationBuilder.DropColumn( - name: "UpdatedAt", - table: "Registries"); - } - } -} diff --git a/Hcs.WebApp/Data/Hcs/Migrations/20251023014411_AddOperation.Designer.cs b/Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.Designer.cs similarity index 82% rename from Hcs.WebApp/Data/Hcs/Migrations/20251023014411_AddOperation.Designer.cs rename to Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.Designer.cs index 81ce2eb..99fb413 100644 --- a/Hcs.WebApp/Data/Hcs/Migrations/20251023014411_AddOperation.Designer.cs +++ b/Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.Designer.cs @@ -7,8 +7,8 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace Hcs.WebApp.Data.Hcs.Migrations { [DbContext(typeof(HcsDbContext))] - [Migration("20251023014411_AddOperation")] - partial class AddOperation + [Migration("20251023092729_CreateHcsSchema")] + public partial class CreateHcsSchema { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -22,8 +22,11 @@ namespace Hcs.WebApp.Data.Hcs.Migrations modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b => { - b.Property("Id") - .HasColumnType("nvarchar(450)"); + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("EndedAt") .HasColumnType("datetime2"); @@ -33,7 +36,6 @@ namespace Hcs.WebApp.Data.Hcs.Migrations .HasColumnType("nvarchar(max)"); b.Property("MessageGuid") - .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("StartedAt") @@ -50,8 +52,9 @@ namespace Hcs.WebApp.Data.Hcs.Migrations modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b => { - b.Property("Id") - .HasColumnType("nvarchar(450)"); + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); b.Property("IsCommon") .HasColumnType("bit"); @@ -73,8 +76,9 @@ namespace Hcs.WebApp.Data.Hcs.Migrations modelBuilder.Entity("Hcs.WebApp.Data.Hcs.RegistryElement", b => { - b.Property("Id") - .HasColumnType("nvarchar(450)"); + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); b.Property("Code") .IsRequired() @@ -84,9 +88,8 @@ namespace Hcs.WebApp.Data.Hcs.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("RegistryId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("RegistryId") + .HasColumnType("uniqueidentifier"); b.Property("Xml") .IsRequired() diff --git a/Hcs.WebApp/Data/Hcs/Migrations/20251022073558_CreateHcsSchema.cs b/Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.cs similarity index 56% rename from Hcs.WebApp/Data/Hcs/Migrations/20251022073558_CreateHcsSchema.cs rename to Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.cs index b18b3d5..a87e5d5 100644 --- a/Hcs.WebApp/Data/Hcs/Migrations/20251022073558_CreateHcsSchema.cs +++ b/Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.cs @@ -9,12 +9,32 @@ namespace Hcs.WebApp.Data.Hcs.Migrations /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "Operations", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Type = table.Column(type: "nvarchar(max)", nullable: false), + InitiatorId = table.Column(type: "nvarchar(max)", nullable: false), + StartedAt = table.Column(type: "datetime2", nullable: false), + EndedAt = table.Column(type: "datetime2", nullable: true), + MessageGuid = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Operations", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Registries", columns: table => new { - Id = table.Column(type: "nvarchar(450)", nullable: false), - Number = table.Column(type: "int", nullable: false) + Id = table.Column(type: "uniqueidentifier", nullable: false), + Number = table.Column(type: "int", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + IsCommon = table.Column(type: "bit", nullable: false), + UpdatedAt = table.Column(type: "datetime2", nullable: false) }, constraints: table => { @@ -25,8 +45,8 @@ namespace Hcs.WebApp.Data.Hcs.Migrations name: "Elements", columns: table => new { - Id = table.Column(type: "nvarchar(450)", nullable: false), - RegistryId = table.Column(type: "nvarchar(450)", nullable: false), + Id = table.Column(type: "uniqueidentifier", nullable: false), + RegistryId = table.Column(type: "uniqueidentifier", nullable: false), Code = table.Column(type: "nvarchar(max)", nullable: false), GUID = table.Column(type: "nvarchar(max)", nullable: false), Xml = table.Column(type: "nvarchar(max)", nullable: false) @@ -54,6 +74,9 @@ namespace Hcs.WebApp.Data.Hcs.Migrations migrationBuilder.DropTable( name: "Elements"); + migrationBuilder.DropTable( + name: "Operations"); + migrationBuilder.DropTable( name: "Registries"); } diff --git a/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs b/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs index 22104ab..cd65ea2 100644 --- a/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs +++ b/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs @@ -19,8 +19,11 @@ namespace Hcs.WebApp.Data.Hcs.Migrations modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b => { - b.Property("Id") - .HasColumnType("nvarchar(450)"); + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("EndedAt") .HasColumnType("datetime2"); @@ -30,7 +33,6 @@ namespace Hcs.WebApp.Data.Hcs.Migrations .HasColumnType("nvarchar(max)"); b.Property("MessageGuid") - .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("StartedAt") @@ -47,8 +49,9 @@ namespace Hcs.WebApp.Data.Hcs.Migrations modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b => { - b.Property("Id") - .HasColumnType("nvarchar(450)"); + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); b.Property("IsCommon") .HasColumnType("bit"); @@ -70,8 +73,9 @@ namespace Hcs.WebApp.Data.Hcs.Migrations modelBuilder.Entity("Hcs.WebApp.Data.Hcs.RegistryElement", b => { - b.Property("Id") - .HasColumnType("nvarchar(450)"); + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); b.Property("Code") .IsRequired() @@ -81,9 +85,8 @@ namespace Hcs.WebApp.Data.Hcs.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("RegistryId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("RegistryId") + .HasColumnType("uniqueidentifier"); b.Property("Xml") .IsRequired() diff --git a/Hcs.WebApp/Data/Hcs/Operation.cs b/Hcs.WebApp/Data/Hcs/Operation.cs index 593721f..299c105 100644 --- a/Hcs.WebApp/Data/Hcs/Operation.cs +++ b/Hcs.WebApp/Data/Hcs/Operation.cs @@ -9,7 +9,7 @@ namespace Hcs.WebApp.Data.Hcs Nsi_15_7_0_1_ExportAllRegistryElements } - public string Id { get; set; } + public int Id { get; set; } public OperationType Type { get; set; } @@ -19,7 +19,7 @@ namespace Hcs.WebApp.Data.Hcs public DateTime? EndedAt { get; set; } - public string MessageGuid { get; set; } + public string? MessageGuid { get; set; } [NotMapped] public bool Completed => EndedAt.HasValue; diff --git a/Hcs.WebApp/Data/Hcs/Registry.cs b/Hcs.WebApp/Data/Hcs/Registry.cs index 6ba1f06..a2fdf84 100644 --- a/Hcs.WebApp/Data/Hcs/Registry.cs +++ b/Hcs.WebApp/Data/Hcs/Registry.cs @@ -2,7 +2,7 @@ { public class Registry { - public string Id { get; set; } + public Guid Id { get; set; } public int Number { get; set; } diff --git a/Hcs.WebApp/Data/Hcs/RegistryElement.cs b/Hcs.WebApp/Data/Hcs/RegistryElement.cs index cb9bd65..0b294d4 100644 --- a/Hcs.WebApp/Data/Hcs/RegistryElement.cs +++ b/Hcs.WebApp/Data/Hcs/RegistryElement.cs @@ -2,9 +2,9 @@ { public class RegistryElement { - public string Id { get; set; } + public Guid Id { get; set; } - public string RegistryId { get; set; } + public Guid RegistryId { get; set; } public virtual Registry Registry { get; set; } = null!;