-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Migrations): cria migração inicial do banco de dados
- Loading branch information
1 parent
950fecf
commit ba69490
Showing
3 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
src/BlazingShop/Data/Migrations/20240625194144_CreateDatabase.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
src/BlazingShop/Data/Migrations/20240625194144_CreateDatabase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace BlazingShop.Data.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class CreateDatabase : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "Category", | ||
columns: table => new | ||
{ | ||
Id = table.Column<int>(type: "INTEGER", nullable: false) | ||
.Annotation("Sqlite:Autoincrement", true), | ||
Title = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Category", x => x.Id); | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "Product", | ||
columns: table => new | ||
{ | ||
Id = table.Column<int>(type: "INTEGER", nullable: false) | ||
.Annotation("Sqlite:Autoincrement", true), | ||
CategoryId = table.Column<int>(type: "INTEGER", nullable: false), | ||
Description = table.Column<string>(type: "TEXT", nullable: false), | ||
Image = table.Column<string>(type: "TEXT", nullable: false), | ||
Price = table.Column<decimal>(type: "TEXT", nullable: false), | ||
Title = table.Column<string>(type: "TEXT", maxLength: 150, nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Product", x => x.Id); | ||
table.ForeignKey( | ||
name: "FK_Product_Category_CategoryId", | ||
column: x => x.CategoryId, | ||
principalTable: "Category", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Cascade); | ||
}); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_Product_CategoryId", | ||
table: "Product", | ||
column: "CategoryId"); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Product"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "Category"); | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
src/BlazingShop/Data/Migrations/AppDbContextModelSnapshot.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// <auto-generated /> | ||
using BlazingShop.Data; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
#nullable disable | ||
|
||
namespace BlazingShop.Data.Migrations | ||
{ | ||
[DbContext(typeof(AppDbContext))] | ||
partial class AppDbContextModelSnapshot : ModelSnapshot | ||
{ | ||
protected override void BuildModel(ModelBuilder modelBuilder) | ||
{ | ||
#pragma warning disable 612, 618 | ||
modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); | ||
|
||
modelBuilder.Entity("BlazingShop.Models.Category", b => | ||
{ | ||
b.Property<int>("Id") | ||
.ValueGeneratedOnAdd() | ||
.HasColumnType("INTEGER"); | ||
b.Property<string>("Title") | ||
.IsRequired() | ||
.HasMaxLength(50) | ||
.HasColumnType("TEXT"); | ||
b.HasKey("Id"); | ||
b.ToTable("Category", (string)null); | ||
}); | ||
|
||
modelBuilder.Entity("BlazingShop.Models.Product", b => | ||
{ | ||
b.Property<int>("Id") | ||
.ValueGeneratedOnAdd() | ||
.HasColumnType("INTEGER"); | ||
b.Property<int>("CategoryId") | ||
.HasColumnType("INTEGER"); | ||
b.Property<string>("Description") | ||
.IsRequired() | ||
.HasColumnType("TEXT"); | ||
b.Property<string>("Image") | ||
.IsRequired() | ||
.HasColumnType("TEXT"); | ||
b.Property<decimal>("Price") | ||
.HasColumnType("TEXT"); | ||
b.Property<string>("Title") | ||
.IsRequired() | ||
.HasMaxLength(150) | ||
.HasColumnType("TEXT"); | ||
b.HasKey("Id"); | ||
b.HasIndex("CategoryId"); | ||
b.ToTable("Product", (string)null); | ||
}); | ||
|
||
modelBuilder.Entity("BlazingShop.Models.Product", b => | ||
{ | ||
b.HasOne("BlazingShop.Models.Category", "Category") | ||
.WithMany("Products") | ||
.HasForeignKey("CategoryId") | ||
.OnDelete(DeleteBehavior.Cascade) | ||
.IsRequired(); | ||
b.Navigation("Category"); | ||
}); | ||
|
||
modelBuilder.Entity("BlazingShop.Models.Category", b => | ||
{ | ||
b.Navigation("Products"); | ||
}); | ||
#pragma warning restore 612, 618 | ||
} | ||
} | ||
} |