using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace WyvernInventory.Infrastructure.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "InventoryTypes", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_InventoryTypes", x => x.Id); }); migrationBuilder.CreateTable( name: "InventoryAttributeDefinitions", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), TypeId = table.Column(type: "int", nullable: true), Name = table.Column(type: "nvarchar(max)", nullable: true), DataType = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_InventoryAttributeDefinitions", x => x.Id); table.ForeignKey( name: "FK_InventoryAttributeDefinitions_InventoryTypes_TypeId", column: x => x.TypeId, principalTable: "InventoryTypes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "InventoryItems", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), TypeId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_InventoryItems", x => x.Id); table.ForeignKey( name: "FK_InventoryItems_InventoryTypes_TypeId", column: x => x.TypeId, principalTable: "InventoryTypes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "InventoryAttributeValues", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ItemId = table.Column(type: "int", nullable: false), AttributeDefinitionId = table.Column(type: "int", nullable: false), StringValue = table.Column(type: "nvarchar(max)", nullable: true), IntValue = table.Column(type: "int", nullable: true), DecimalValue = table.Column(type: "decimal(18,2)", nullable: true), BoolValue = table.Column(type: "bit", nullable: true), DateTimeValue = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_InventoryAttributeValues", x => x.Id); table.ForeignKey( name: "FK_InventoryAttributeValues_InventoryAttributeDefinitions_AttributeDefinitionId", column: x => x.AttributeDefinitionId, principalTable: "InventoryAttributeDefinitions", principalColumn: "Id"); table.ForeignKey( name: "FK_InventoryAttributeValues_InventoryItems_ItemId", column: x => x.ItemId, principalTable: "InventoryItems", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_InventoryAttributeDefinitions_TypeId", table: "InventoryAttributeDefinitions", column: "TypeId"); migrationBuilder.CreateIndex( name: "IX_InventoryAttributeValues_AttributeDefinitionId", table: "InventoryAttributeValues", column: "AttributeDefinitionId"); migrationBuilder.CreateIndex( name: "IX_InventoryAttributeValues_ItemId_AttributeDefinitionId", table: "InventoryAttributeValues", columns: new[] { "ItemId", "AttributeDefinitionId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_InventoryItems_TypeId", table: "InventoryItems", column: "TypeId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "InventoryAttributeValues"); migrationBuilder.DropTable( name: "InventoryAttributeDefinitions"); migrationBuilder.DropTable( name: "InventoryItems"); migrationBuilder.DropTable( name: "InventoryTypes"); } } }