Skip to content

Commit a45a2e4

Browse files
feat: adição do arquivo 20211022000603_Inicial.cs
1 parent db93139 commit a45a2e4

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
using Microsoft.EntityFrameworkCore.Metadata;
2+
using Microsoft.EntityFrameworkCore.Migrations;
3+
4+
namespace Alura.ByteBank.Dados.Migrations
5+
{
6+
public partial class Inicial : Migration
7+
{
8+
protected override void Up(MigrationBuilder migrationBuilder)
9+
{
10+
migrationBuilder.AlterDatabase()
11+
.Annotation("MySql:CharSet", "utf8mb4");
12+
13+
migrationBuilder.CreateTable(
14+
name: "agencia",
15+
columns: table => new
16+
{
17+
Id = table.Column<int>(type: "int", nullable: false)
18+
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
19+
Numero = table.Column<int>(type: "int", nullable: false),
20+
Nome = table.Column<string>(type: "longtext", nullable: false)
21+
.Annotation("MySql:CharSet", "utf8mb4"),
22+
Endereco = table.Column<string>(type: "longtext", nullable: true)
23+
.Annotation("MySql:CharSet", "utf8mb4")
24+
},
25+
constraints: table =>
26+
{
27+
table.PrimaryKey("PK_agencia", x => x.Id);
28+
})
29+
.Annotation("MySql:CharSet", "utf8mb4");
30+
31+
migrationBuilder.CreateTable(
32+
name: "cliente",
33+
columns: table => new
34+
{
35+
Id = table.Column<int>(type: "int", nullable: false)
36+
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
37+
CPF = table.Column<string>(type: "longtext", nullable: false)
38+
.Annotation("MySql:CharSet", "utf8mb4"),
39+
Nome = table.Column<string>(type: "longtext", nullable: false)
40+
.Annotation("MySql:CharSet", "utf8mb4"),
41+
Profissao = table.Column<string>(type: "longtext", nullable: false)
42+
.Annotation("MySql:CharSet", "utf8mb4")
43+
},
44+
constraints: table =>
45+
{
46+
table.PrimaryKey("PK_cliente", x => x.Id);
47+
})
48+
.Annotation("MySql:CharSet", "utf8mb4");
49+
50+
migrationBuilder.CreateTable(
51+
name: "conta_corrente",
52+
columns: table => new
53+
{
54+
Id = table.Column<int>(type: "int", nullable: false)
55+
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
56+
Numero = table.Column<int>(type: "int", nullable: false),
57+
ClienteId = table.Column<int>(type: "int", nullable: false),
58+
AgenciaId = table.Column<int>(type: "int", nullable: false),
59+
Saldo = table.Column<double>(type: "double", nullable: false)
60+
},
61+
constraints: table =>
62+
{
63+
table.PrimaryKey("PK_conta_corrente", x => x.Id);
64+
table.ForeignKey(
65+
name: "FK_conta_corrente_agencia_AgenciaId",
66+
column: x => x.AgenciaId,
67+
principalTable: "agencia",
68+
principalColumn: "Id",
69+
onDelete: ReferentialAction.Cascade);
70+
table.ForeignKey(
71+
name: "FK_conta_corrente_cliente_ClienteId",
72+
column: x => x.ClienteId,
73+
principalTable: "cliente",
74+
principalColumn: "Id",
75+
onDelete: ReferentialAction.Cascade);
76+
})
77+
.Annotation("MySql:CharSet", "utf8mb4");
78+
79+
migrationBuilder.CreateIndex(
80+
name: "IX_conta_corrente_AgenciaId",
81+
table: "conta_corrente",
82+
column: "AgenciaId");
83+
84+
migrationBuilder.CreateIndex(
85+
name: "IX_conta_corrente_ClienteId",
86+
table: "conta_corrente",
87+
column: "ClienteId");
88+
}
89+
90+
protected override void Down(MigrationBuilder migrationBuilder)
91+
{
92+
migrationBuilder.DropTable(
93+
name: "conta_corrente");
94+
95+
migrationBuilder.DropTable(
96+
name: "agencia");
97+
98+
migrationBuilder.DropTable(
99+
name: "cliente");
100+
}
101+
}
102+
}

0 commit comments

Comments
 (0)