using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Hcs.WebApp.Data.Hcs.Migrations { /// public partial class CreateHcsSchema : Migration { /// 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: "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 => { table.PrimaryKey("PK_Registries", x => x.Id); }); migrationBuilder.CreateTable( name: "Elements", columns: table => new { 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) }, 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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Elements"); migrationBuilder.DropTable( name: "Operations"); migrationBuilder.DropTable( name: "Registries"); } } }