diff --git a/src/BlazingShop/Data/Migrations/20240625194144_CreateDatabase.Designer.cs b/src/BlazingShop/Data/Migrations/20240625194144_CreateDatabase.Designer.cs new file mode 100644 index 0000000..bb04737 --- /dev/null +++ b/src/BlazingShop/Data/Migrations/20240625194144_CreateDatabase.Designer.cs @@ -0,0 +1,88 @@ +// +using BlazingShop.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlazingShop.Data.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20240625194144_CreateDatabase")] + partial class CreateDatabase + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.6"); + + modelBuilder.Entity("BlazingShop.Models.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Category", (string)null); + }); + + modelBuilder.Entity("BlazingShop.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CategoryId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Image") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/src/BlazingShop/Data/Migrations/20240625194144_CreateDatabase.cs b/src/BlazingShop/Data/Migrations/20240625194144_CreateDatabase.cs new file mode 100644 index 0000000..2382169 --- /dev/null +++ b/src/BlazingShop/Data/Migrations/20240625194144_CreateDatabase.cs @@ -0,0 +1,65 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlazingShop.Data.Migrations +{ + /// + public partial class CreateDatabase : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Category", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Title = table.Column(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(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + CategoryId = table.Column(type: "INTEGER", nullable: false), + Description = table.Column(type: "TEXT", nullable: false), + Image = table.Column(type: "TEXT", nullable: false), + Price = table.Column(type: "TEXT", nullable: false), + Title = table.Column(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"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Product"); + + migrationBuilder.DropTable( + name: "Category"); + } + } +} diff --git a/src/BlazingShop/Data/Migrations/AppDbContextModelSnapshot.cs b/src/BlazingShop/Data/Migrations/AppDbContextModelSnapshot.cs new file mode 100644 index 0000000..5303bf9 --- /dev/null +++ b/src/BlazingShop/Data/Migrations/AppDbContextModelSnapshot.cs @@ -0,0 +1,85 @@ +// +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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Category", (string)null); + }); + + modelBuilder.Entity("BlazingShop.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CategoryId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Image") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("TEXT"); + + b.Property("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 + } + } +}