|
| 1 | +using Microsoft.EntityFrameworkCore.Migrations; |
| 2 | + |
| 3 | +namespace OnlineStore.Migrations |
| 4 | +{ |
| 5 | + public partial class AddressesTableCreated : Migration |
| 6 | + { |
| 7 | + protected override void Up(MigrationBuilder migrationBuilder) |
| 8 | + { |
| 9 | + migrationBuilder.AlterColumn<string>( |
| 10 | + name: "Name", |
| 11 | + table: "Products", |
| 12 | + nullable: false, |
| 13 | + oldClrType: typeof(string), |
| 14 | + oldType: "nvarchar(max)", |
| 15 | + oldNullable: true); |
| 16 | + |
| 17 | + migrationBuilder.AlterColumn<string>( |
| 18 | + name: "Description", |
| 19 | + table: "Products", |
| 20 | + nullable: false, |
| 21 | + oldClrType: typeof(string), |
| 22 | + oldType: "nvarchar(max)", |
| 23 | + oldNullable: true); |
| 24 | + |
| 25 | + migrationBuilder.CreateTable( |
| 26 | + name: "Addresses", |
| 27 | + columns: table => new |
| 28 | + { |
| 29 | + Id = table.Column<int>(nullable: false) |
| 30 | + .Annotation("SqlServer:Identity", "1, 1"), |
| 31 | + Cep = table.Column<string>(maxLength: 8, nullable: false), |
| 32 | + State = table.Column<string>(nullable: false), |
| 33 | + City = table.Column<string>(nullable: false), |
| 34 | + Neighborhood = table.Column<string>(nullable: false), |
| 35 | + AddressLine = table.Column<string>(nullable: false), |
| 36 | + Complement = table.Column<string>(nullable: true), |
| 37 | + Number = table.Column<string>(nullable: false) |
| 38 | + }, |
| 39 | + constraints: table => |
| 40 | + { |
| 41 | + table.PrimaryKey("PK_Addresses", x => x.Id); |
| 42 | + }); |
| 43 | + } |
| 44 | + |
| 45 | + protected override void Down(MigrationBuilder migrationBuilder) |
| 46 | + { |
| 47 | + migrationBuilder.DropTable( |
| 48 | + name: "Addresses"); |
| 49 | + |
| 50 | + migrationBuilder.AlterColumn<string>( |
| 51 | + name: "Name", |
| 52 | + table: "Products", |
| 53 | + type: "nvarchar(max)", |
| 54 | + nullable: true, |
| 55 | + oldClrType: typeof(string)); |
| 56 | + |
| 57 | + migrationBuilder.AlterColumn<string>( |
| 58 | + name: "Description", |
| 59 | + table: "Products", |
| 60 | + type: "nvarchar(max)", |
| 61 | + nullable: true, |
| 62 | + oldClrType: typeof(string)); |
| 63 | + } |
| 64 | + } |
| 65 | +} |
0 commit comments