using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DEMO.Migrations
{
///
public partial class AddStock : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Stocks",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProductId = table.Column(type: "int", nullable: false),
WarehouseId = table.Column(type: "int", nullable: false),
Quantity = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Stocks", x => x.Id);
table.ForeignKey(
name: "FK_Stocks_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Stocks_Warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "Warehouses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Stocks_ProductId",
table: "Stocks",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_Stocks_WarehouseId",
table: "Stocks",
column: "WarehouseId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Stocks");
}
}
}