20200218022312_Init.cs
2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Microsoft.EntityFrameworkCore.Migrations;
namespace Backet.Api.Migrations
{
public partial class Init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Backet",
columns: table => new
{
Id = table.Column<string>(maxLength: 32, nullable: false),
UserId = table.Column<string>(maxLength: 32, nullable: false),
TotalPrice = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Backet", x => x.Id);
});
migrationBuilder.CreateTable(
name: "BacketItem",
columns: table => new
{
Id = table.Column<string>(maxLength: 32, nullable: false),
ProductId = table.Column<string>(maxLength: 32, nullable: true),
ProductName = table.Column<string>(maxLength: 256, nullable: false),
Price = table.Column<long>(nullable: false),
BacketId = table.Column<string>(maxLength: 32, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BacketItem", x => x.Id);
table.ForeignKey(
name: "FK_BacketItem_Backet_BacketId",
column: x => x.BacketId,
principalTable: "Backet",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Backet_UserId",
table: "Backet",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_BacketItem_BacketId",
table: "BacketItem",
column: "BacketId");
migrationBuilder.CreateIndex(
name: "IX_BacketItem_ProductId",
table: "BacketItem",
column: "ProductId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BacketItem");
migrationBuilder.DropTable(
name: "Backet");
}
}
}