132 lines
5.8 KiB
C#
132 lines
5.8 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
namespace Hcs.WebApp.Data.Hcs.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class CreateHcsSchema : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
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),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
StartedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
EndedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
Step = table.Column<int>(type: "int", nullable: false),
|
|
Progress = table.Column<int>(type: "int", nullable: false),
|
|
FailureReason = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
},
|
|
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: true)
|
|
},
|
|
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(
|
|
name: "Registries",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
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),
|
|
SyncedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
LastSyncOperationId = table.Column<int>(type: "int", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Registries", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Registries_Operations_LastSyncOperationId",
|
|
column: x => x.LastSyncOperationId,
|
|
principalTable: "Operations",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Elements",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
RegistryId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
Code = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
GUID = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Json = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Elements", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Elements_Registries_RegistryId",
|
|
column: x => x.RegistryId,
|
|
principalTable: "Registries",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
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 />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Elements");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Registries");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Operations");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Campaigns");
|
|
}
|
|
}
|
|
}
|