a76785e602
Added EAV inventory types Added EAV object handling philosophy Added controllers Added EF Core migration integration
137 lines
5.8 KiB
C#
137 lines
5.8 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace WyvernInventory.Infrastructure.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialCreate : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "InventoryTypes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_InventoryTypes", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "InventoryAttributeDefinitions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
TypeId = table.Column<int>(type: "int", nullable: true),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
DataType = table.Column<int>(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<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
TypeId = table.Column<int>(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<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ItemId = table.Column<int>(type: "int", nullable: false),
|
|
AttributeDefinitionId = table.Column<int>(type: "int", nullable: false),
|
|
StringValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IntValue = table.Column<int>(type: "int", nullable: true),
|
|
DecimalValue = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
|
|
BoolValue = table.Column<bool>(type: "bit", nullable: true),
|
|
DateTimeValue = table.Column<DateTime>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "InventoryAttributeValues");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "InventoryAttributeDefinitions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "InventoryItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "InventoryTypes");
|
|
}
|
|
}
|
|
}
|