Create new migration

This commit is contained in:
2025-10-28 15:39:10 +09:00
parent c8686a5899
commit 53df5e1767
3 changed files with 232 additions and 12 deletions

View File

@ -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
{
/// <inheritdoc />
@ -20,6 +20,43 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Campaign", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<DateTime?>("EndedAt")
.HasColumnType("datetime2");
b.Property<string>("FailureReason")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("InitiatorId")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("StartedAt")
.HasColumnType("datetime2");
b.Property<int>("Step")
.HasColumnType("int");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Campaigns");
});
modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b =>
{
b.Property<int>("Id")
@ -28,17 +65,23 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CampaignId")
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<DateTime?>("EndedAt")
.HasColumnType("datetime2");
b.Property<string>("InitiatorId")
b.Property<string>("FailureReason")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("MessageGuid")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("StartedAt")
b.Property<DateTime?>("StartedAt")
.HasColumnType("datetime2");
b.Property<string>("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<bool>("IsCommon")
.HasColumnType("bit");
b.Property<string>("LastSyncError")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("LastSyncOperationId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
@ -66,11 +118,13 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.Property<int>("Number")
.HasColumnType("int");
b.Property<DateTime>("UpdatedAt")
b.Property<DateTime?>("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");

View File

@ -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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Type = table.Column<string>(type: "nvarchar(max)", nullable: false),
InitiatorId = table.Column<string>(type: "nvarchar(max)", nullable: false),
StartedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
StartedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
EndedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
MessageGuid = table.Column<string>(type: "nvarchar(max)", nullable: true)
Step = table.Column<int>(type: "int", nullable: false),
FailureReason = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Campaigns", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Operations",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CampaignId = table.Column<int>(type: "int", nullable: false),
Type = table.Column<string>(type: "nvarchar(max)", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
StartedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
EndedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
MessageGuid = table.Column<string>(type: "nvarchar(max)", nullable: true),
FailureReason = table.Column<string>(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<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
IsCommon = table.Column<bool>(type: "bit", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
SyncedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
LastSyncOperationId = table.Column<int>(type: "int", nullable: false),
LastSyncError = table.Column<string>(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");
}
/// <inheritdoc />
@ -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");
}
}
}

View File

@ -17,6 +17,43 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Campaign", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<DateTime?>("EndedAt")
.HasColumnType("datetime2");
b.Property<string>("FailureReason")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("InitiatorId")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("StartedAt")
.HasColumnType("datetime2");
b.Property<int>("Step")
.HasColumnType("int");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Campaigns");
});
modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b =>
{
b.Property<int>("Id")
@ -25,17 +62,23 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CampaignId")
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<DateTime?>("EndedAt")
.HasColumnType("datetime2");
b.Property<string>("InitiatorId")
b.Property<string>("FailureReason")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("MessageGuid")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("StartedAt")
b.Property<DateTime?>("StartedAt")
.HasColumnType("datetime2");
b.Property<string>("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<bool>("IsCommon")
.HasColumnType("bit");
b.Property<string>("LastSyncError")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("LastSyncOperationId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
@ -63,11 +115,13 @@ namespace Hcs.WebApp.Data.Hcs.Migrations
b.Property<int>("Number")
.HasColumnType("int");
b.Property<DateTime>("UpdatedAt")
b.Property<DateTime?>("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");