-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20221225101617_mig_1.cs
More file actions
115 lines (104 loc) · 4.51 KB
/
Copy path20221225101617_mig_1.cs
File metadata and controls
115 lines (104 loc) · 4.51 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ETicaretAPI.Persistence.Migrations
{
/// <inheritdoc />
public partial class mig1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Customers",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
CreateDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Customers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Stock = table.Column<int>(type: "integer", nullable: false),
Price = table.Column<long>(type: "bigint", nullable: false),
CreateDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
CustomerId = table.Column<int>(type: "integer", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
Address = table.Column<string>(type: "text", nullable: false),
CustomerId1 = table.Column<Guid>(type: "uuid", nullable: false),
CreateDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Customers_CustomerId1",
column: x => x.CustomerId1,
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "OrderProduct",
columns: table => new
{
OrdersId = table.Column<Guid>(type: "uuid", nullable: false),
ProductsId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrderProduct", x => new { x.OrdersId, x.ProductsId });
table.ForeignKey(
name: "FK_OrderProduct_Orders_OrdersId",
column: x => x.OrdersId,
principalTable: "Orders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_OrderProduct_Products_ProductsId",
column: x => x.ProductsId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_OrderProduct_ProductsId",
table: "OrderProduct",
column: "ProductsId");
migrationBuilder.CreateIndex(
name: "IX_Orders_CustomerId1",
table: "Orders",
column: "CustomerId1");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "OrderProduct");
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "Products");
migrationBuilder.DropTable(
name: "Customers");
}
}
}