diff --git a/Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.Designer.cs b/Hcs.WebApp/Data/Hcs/Migrations/20251028063057_CreateHcsSchema.Designer.cs
similarity index 55%
rename from Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.Designer.cs
rename to Hcs.WebApp/Data/Hcs/Migrations/20251028063057_CreateHcsSchema.Designer.cs
index 99fb413..9e6f3fa 100644
--- a/Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.Designer.cs
+++ b/Hcs.WebApp/Data/Hcs/Migrations/20251028063057_CreateHcsSchema.Designer.cs
@@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Hcs.WebApp.Data.Hcs.Migrations
{
[DbContext(typeof(HcsDbContext))]
- [Migration("20251023092729_CreateHcsSchema")]
+ [Migration("20251028063057_CreateHcsSchema")]
public partial class CreateHcsSchema
{
///
@@ -20,6 +20,43 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+ modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Campaign", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime2");
+
+ b.Property("EndedAt")
+ .HasColumnType("datetime2");
+
+ b.Property("FailureReason")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("InitiatorId")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("StartedAt")
+ .HasColumnType("datetime2");
+
+ b.Property("Step")
+ .HasColumnType("int");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Campaigns");
+ });
+
modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b =>
{
b.Property("Id")
@@ -28,17 +65,23 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ b.Property("CampaignId")
+ .HasColumnType("int");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime2");
+
b.Property("EndedAt")
.HasColumnType("datetime2");
- b.Property("InitiatorId")
+ b.Property("FailureReason")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property("MessageGuid")
.HasColumnType("nvarchar(max)");
- b.Property("StartedAt")
+ b.Property("StartedAt")
.HasColumnType("datetime2");
b.Property("Type")
@@ -47,6 +90,8 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.HasKey("Id");
+ b.HasIndex("CampaignId");
+
b.ToTable("Operations");
});
@@ -59,6 +104,13 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.Property("IsCommon")
.HasColumnType("bit");
+ b.Property("LastSyncError")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("LastSyncOperationId")
+ .HasColumnType("int");
+
b.Property("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -66,11 +118,13 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.Property("Number")
.HasColumnType("int");
- b.Property("UpdatedAt")
+ b.Property("SyncedAt")
.HasColumnType("datetime2");
b.HasKey("Id");
+ b.HasIndex("LastSyncOperationId");
+
b.ToTable("Registries");
});
@@ -102,6 +156,28 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.ToTable("Elements");
});
+ modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b =>
+ {
+ b.HasOne("Hcs.WebApp.Data.Hcs.Campaign", "Campaign")
+ .WithMany("Operations")
+ .HasForeignKey("CampaignId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Campaign");
+ });
+
+ modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b =>
+ {
+ b.HasOne("Hcs.WebApp.Data.Hcs.Operation", "LastSyncOperation")
+ .WithMany("Registries")
+ .HasForeignKey("LastSyncOperationId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("LastSyncOperation");
+ });
+
modelBuilder.Entity("Hcs.WebApp.Data.Hcs.RegistryElement", b =>
{
b.HasOne("Hcs.WebApp.Data.Hcs.Registry", "Registry")
@@ -113,6 +189,16 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.Navigation("Registry");
});
+ modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Campaign", b =>
+ {
+ b.Navigation("Operations");
+ });
+
+ modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b =>
+ {
+ b.Navigation("Registries");
+ });
+
modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b =>
{
b.Navigation("Elements");
diff --git a/Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.cs b/Hcs.WebApp/Data/Hcs/Migrations/20251028063057_CreateHcsSchema.cs
similarity index 56%
rename from Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.cs
rename to Hcs.WebApp/Data/Hcs/Migrations/20251028063057_CreateHcsSchema.cs
index a87e5d5..7039d46 100644
--- a/Hcs.WebApp/Data/Hcs/Migrations/20251023092729_CreateHcsSchema.cs
+++ b/Hcs.WebApp/Data/Hcs/Migrations/20251028063057_CreateHcsSchema.cs
@@ -10,20 +10,47 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
- name: "Operations",
+ name: "Campaigns",
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),
+ CreatedAt = table.Column(type: "datetime2", nullable: false),
+ StartedAt = table.Column(type: "datetime2", nullable: true),
EndedAt = table.Column(type: "datetime2", nullable: true),
- MessageGuid = table.Column(type: "nvarchar(max)", nullable: true)
+ Step = table.Column(type: "int", nullable: false),
+ FailureReason = table.Column(type: "nvarchar(max)", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Campaigns", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Operations",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ CampaignId = table.Column(type: "int", nullable: false),
+ Type = table.Column(type: "nvarchar(max)", nullable: false),
+ CreatedAt = table.Column(type: "datetime2", nullable: false),
+ StartedAt = table.Column(type: "datetime2", nullable: true),
+ EndedAt = table.Column(type: "datetime2", nullable: true),
+ MessageGuid = table.Column(type: "nvarchar(max)", nullable: true),
+ FailureReason = table.Column(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Operations", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Operations_Campaigns_CampaignId",
+ column: x => x.CampaignId,
+ principalTable: "Campaigns",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@@ -34,11 +61,19 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
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)
+ SyncedAt = table.Column(type: "datetime2", nullable: true),
+ LastSyncOperationId = table.Column(type: "int", nullable: false),
+ LastSyncError = table.Column(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Registries", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Registries_Operations_LastSyncOperationId",
+ column: x => x.LastSyncOperationId,
+ principalTable: "Operations",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@@ -66,6 +101,16 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
name: "IX_Elements_RegistryId",
table: "Elements",
column: "RegistryId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Operations_CampaignId",
+ table: "Operations",
+ column: "CampaignId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Registries_LastSyncOperationId",
+ table: "Registries",
+ column: "LastSyncOperationId");
}
///
@@ -74,11 +119,14 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
migrationBuilder.DropTable(
name: "Elements");
+ migrationBuilder.DropTable(
+ name: "Registries");
+
migrationBuilder.DropTable(
name: "Operations");
migrationBuilder.DropTable(
- name: "Registries");
+ name: "Campaigns");
}
}
}
diff --git a/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs b/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs
index cd65ea2..74d8b13 100644
--- a/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs
+++ b/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs
@@ -17,6 +17,43 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+ modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Campaign", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime2");
+
+ b.Property("EndedAt")
+ .HasColumnType("datetime2");
+
+ b.Property("FailureReason")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("InitiatorId")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("StartedAt")
+ .HasColumnType("datetime2");
+
+ b.Property("Step")
+ .HasColumnType("int");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Campaigns");
+ });
+
modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b =>
{
b.Property("Id")
@@ -25,17 +62,23 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ b.Property("CampaignId")
+ .HasColumnType("int");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime2");
+
b.Property("EndedAt")
.HasColumnType("datetime2");
- b.Property("InitiatorId")
+ b.Property("FailureReason")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property("MessageGuid")
.HasColumnType("nvarchar(max)");
- b.Property("StartedAt")
+ b.Property("StartedAt")
.HasColumnType("datetime2");
b.Property("Type")
@@ -44,6 +87,8 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.HasKey("Id");
+ b.HasIndex("CampaignId");
+
b.ToTable("Operations");
});
@@ -56,6 +101,13 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.Property("IsCommon")
.HasColumnType("bit");
+ b.Property("LastSyncError")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("LastSyncOperationId")
+ .HasColumnType("int");
+
b.Property("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -63,11 +115,13 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.Property("Number")
.HasColumnType("int");
- b.Property("UpdatedAt")
+ b.Property("SyncedAt")
.HasColumnType("datetime2");
b.HasKey("Id");
+ b.HasIndex("LastSyncOperationId");
+
b.ToTable("Registries");
});
@@ -99,6 +153,28 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.ToTable("Elements");
});
+ modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b =>
+ {
+ b.HasOne("Hcs.WebApp.Data.Hcs.Campaign", "Campaign")
+ .WithMany("Operations")
+ .HasForeignKey("CampaignId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Campaign");
+ });
+
+ modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b =>
+ {
+ b.HasOne("Hcs.WebApp.Data.Hcs.Operation", "LastSyncOperation")
+ .WithMany("Registries")
+ .HasForeignKey("LastSyncOperationId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("LastSyncOperation");
+ });
+
modelBuilder.Entity("Hcs.WebApp.Data.Hcs.RegistryElement", b =>
{
b.HasOne("Hcs.WebApp.Data.Hcs.Registry", "Registry")
@@ -110,6 +186,16 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.Navigation("Registry");
});
+ modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Campaign", b =>
+ {
+ b.Navigation("Operations");
+ });
+
+ modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b =>
+ {
+ b.Navigation("Registries");
+ });
+
modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b =>
{
b.Navigation("Elements");