using Microsoft.EntityFrameworkCore.Migrations; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConfectioneryDatabaseImplement.Migrations { public partial class InitialCreate : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Ingredients", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), IngredientName = table.Column(type: "nvarchar(max)", nullable: false), Cost = table.Column(type: "float", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Ingredients", x => x.Id); }); migrationBuilder.CreateTable( name: "ListSweets", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), SweetsName = table.Column(type: "nvarchar(max)", nullable: false), Price = table.Column(type: "float", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ListSweets", x => x.Id); }); migrationBuilder.CreateTable( name: "Orders", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), SweetsId = table.Column(type: "int", nullable: false), Count = table.Column(type: "int", nullable: false), Sum = table.Column(type: "float", nullable: false), Status = table.Column(type: "int", nullable: false), DateCreate = table.Column(type: "datetime2", nullable: false), DateImplement = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Orders", x => x.Id); table.ForeignKey( name: "FK_Orders_ListSweets_SweetsId", column: x => x.SweetsId, principalTable: "ListSweets", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "SweetsIngredients", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), SweetsId = table.Column(type: "int", nullable: false), IngredientId = table.Column(type: "int", nullable: false), Count = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_SweetsIngredients", x => x.Id); table.ForeignKey( name: "FK_SweetsIngredients_Ingredients_IngredientId", column: x => x.IngredientId, principalTable: "Ingredients", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_SweetsIngredients_ListSweets_SweetsId", column: x => x.SweetsId, principalTable: "ListSweets", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Orders_SweetsId", table: "Orders", column: "SweetsId"); migrationBuilder.CreateIndex( name: "IX_SweetsIngredients_IngredientId", table: "SweetsIngredients", column: "IngredientId"); migrationBuilder.CreateIndex( name: "IX_SweetsIngredients_SweetsId", table: "SweetsIngredients", column: "SweetsId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Orders"); migrationBuilder.DropTable( name: "SweetsIngredients"); migrationBuilder.DropTable( name: "Ingredients"); migrationBuilder.DropTable( name: "ListSweets"); } } }