From 096397aafb739c9866ecf7295108cc112c72e603 Mon Sep 17 00:00:00 2001 From: JakobSA Date: Thu, 28 Nov 2024 21:15:12 +0100 Subject: [PATCH] Changed migrations --- Backend/Backend.csproj | 2 +- .../20241107153159_InitialCreate.Designer.cs | 221 ------------------ .../20241107153159_InitialCreate.cs | 141 ----------- ....cs => 20241128201401_Initial.Designer.cs} | 26 ++- ...5046_init.cs => 20241128201401_Initial.cs} | 11 +- .../DatabaseContextModelSnapshot.cs | 36 ++- Frontend/src/services/imageService.ts | 2 +- 7 files changed, 52 insertions(+), 387 deletions(-) delete mode 100644 Backend/Migrations/20241107153159_InitialCreate.Designer.cs delete mode 100644 Backend/Migrations/20241107153159_InitialCreate.cs rename Backend/Migrations/{20241115185046_init.Designer.cs => 20241128201401_Initial.Designer.cs} (93%) rename Backend/Migrations/{20241115185046_init.cs => 20241128201401_Initial.cs} (93%) diff --git a/Backend/Backend.csproj b/Backend/Backend.csproj index 6541bb0..ac1952e 100644 --- a/Backend/Backend.csproj +++ b/Backend/Backend.csproj @@ -10,7 +10,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Backend/Migrations/20241107153159_InitialCreate.Designer.cs b/Backend/Migrations/20241107153159_InitialCreate.Designer.cs deleted file mode 100644 index 2ba2eb8..0000000 --- a/Backend/Migrations/20241107153159_InitialCreate.Designer.cs +++ /dev/null @@ -1,221 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Backend.Migrations -{ - [DbContext(typeof(DatabaseContext))] - [Migration("20241107153159_InitialCreate")] - partial class InitialCreate - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("AuctionWare", b => - { - b.Property("ItemId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ItemId")); - - b.Property("AuctionEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("AuctionStart") - .HasColumnType("timestamp with time zone"); - - b.Property("AuctionStatus") - .HasColumnType("integer"); - - b.Property("BuyerId") - .HasColumnType("integer"); - - b.Property("CurrentPrice") - .HasColumnType("integer"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("HighestBidderId") - .HasColumnType("integer"); - - b.Property("ItemName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("MinimumPrice") - .HasColumnType("integer"); - - b.Property("SellerId") - .HasColumnType("integer"); - - b.HasKey("ItemId"); - - b.ToTable("AuctionWare"); - }); - - modelBuilder.Entity("Bid", b => - { - b.Property("BidId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BidId")); - - b.Property("BidAmmount") - .HasColumnType("integer"); - - b.Property("BidTime") - .HasColumnType("timestamp with time zone"); - - b.Property("BidderId") - .HasColumnType("integer"); - - b.Property("ItemId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("BidId"); - - b.ToTable("Bid"); - }); - - modelBuilder.Entity("Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CategoryId")); - - b.Property("CategoryName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.HasKey("CategoryId"); - - b.ToTable("Category"); - }); - - modelBuilder.Entity("CategoryJunction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("CategoryId") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("CategoryJunction"); - }); - - modelBuilder.Entity("Customer", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("CustomerId")); - - b.Property("AccountType") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Password") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasMaxLength(15) - .HasColumnType("character varying(15)"); - - b.Property("RegistrationDate") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CustomerId"); - - b.ToTable("Customer"); - }); - - modelBuilder.Entity("Transaction", b => - { - b.Property("TransactionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransactionId")); - - b.Property("BuyerId") - .HasColumnType("integer"); - - b.Property("FinalPrice") - .HasColumnType("integer"); - - b.Property("ItemId") - .HasColumnType("integer"); - - b.Property("SellerId") - .HasColumnType("integer"); - - b.Property("TransactionDate") - .HasColumnType("timestamp with time zone"); - - b.HasKey("TransactionId"); - - b.ToTable("Transaction"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Backend/Migrations/20241107153159_InitialCreate.cs b/Backend/Migrations/20241107153159_InitialCreate.cs deleted file mode 100644 index b28cb90..0000000 --- a/Backend/Migrations/20241107153159_InitialCreate.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Backend.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AuctionWare", - columns: table => new - { - ItemId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ItemName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - Description = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - MinimumPrice = table.Column(type: "integer", nullable: false), - CurrentPrice = table.Column(type: "integer", nullable: false), - AuctionStart = table.Column(type: "timestamp with time zone", nullable: false), - AuctionEnd = table.Column(type: "timestamp with time zone", nullable: false), - SellerId = table.Column(type: "integer", nullable: false), - HighestBidderId = table.Column(type: "integer", nullable: true), - BuyerId = table.Column(type: "integer", nullable: true), - AuctionStatus = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AuctionWare", x => x.ItemId); - }); - - migrationBuilder.CreateTable( - name: "Bid", - columns: table => new - { - BidId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ItemId = table.Column(type: "text", nullable: false), - BidderId = table.Column(type: "integer", nullable: false), - BidAmmount = table.Column(type: "integer", nullable: false), - BidTime = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Bid", x => x.BidId); - }); - - migrationBuilder.CreateTable( - name: "Category", - columns: table => new - { - CategoryId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - CategoryName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - Description = table.Column(type: "character varying(200)", maxLength: 200, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Category", x => x.CategoryId); - }); - - migrationBuilder.CreateTable( - name: "CategoryJunction", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ItemId = table.Column(type: "integer", nullable: false), - CategoryId = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CategoryJunction", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Customer", - columns: table => new - { - CustomerId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - FirstName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - LastName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - Email = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), - Password = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), - Address = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), - PhoneNumber = table.Column(type: "character varying(15)", maxLength: 15, nullable: false), - AccountType = table.Column(type: "integer", nullable: false), - RegistrationDate = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Customer", x => x.CustomerId); - }); - - migrationBuilder.CreateTable( - name: "Transaction", - columns: table => new - { - TransactionId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ItemId = table.Column(type: "integer", nullable: false), - SellerId = table.Column(type: "integer", nullable: false), - BuyerId = table.Column(type: "integer", nullable: false), - FinalPrice = table.Column(type: "integer", nullable: false), - TransactionDate = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Transaction", x => x.TransactionId); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AuctionWare"); - - migrationBuilder.DropTable( - name: "Bid"); - - migrationBuilder.DropTable( - name: "Category"); - - migrationBuilder.DropTable( - name: "CategoryJunction"); - - migrationBuilder.DropTable( - name: "Customer"); - - migrationBuilder.DropTable( - name: "Transaction"); - } - } -} diff --git a/Backend/Migrations/20241115185046_init.Designer.cs b/Backend/Migrations/20241128201401_Initial.Designer.cs similarity index 93% rename from Backend/Migrations/20241115185046_init.Designer.cs rename to Backend/Migrations/20241128201401_Initial.Designer.cs index 2cff76d..d1df2c0 100644 --- a/Backend/Migrations/20241115185046_init.Designer.cs +++ b/Backend/Migrations/20241128201401_Initial.Designer.cs @@ -11,20 +11,20 @@ namespace Backend.Migrations { [DbContext(typeof(DatabaseContext))] - [Migration("20241115185046_init")] - partial class init + [Migration("20241128201401_Initial")] + partial class Initial { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("ProductVersion", "8.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("AuctionWare", b => + modelBuilder.Entity("Backend.Models.AuctionWare", b => { b.Property("ItemId") .ValueGeneratedOnAdd() @@ -79,7 +79,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BidId")); - b.Property("BidAmmount") + b.Property("BidAmount") .HasColumnType("integer"); b.Property("BidTime") @@ -88,9 +88,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BidderId") .HasColumnType("integer"); - b.Property("ItemId") - .IsRequired() - .HasColumnType("text"); + b.Property("ItemId") + .HasColumnType("integer"); b.HasKey("BidId"); @@ -196,15 +195,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ImageId")); - b.Property("ImageBlob") - .IsRequired() - .HasColumnType("bytea"); + b.Property("AuctionWareId") + .HasColumnType("integer"); - b.Property("Name") + b.Property("ContentType") .IsRequired() .HasMaxLength(200) .HasColumnType("character varying(200)"); + b.Property("Data") + .IsRequired() + .HasColumnType("bytea"); + b.HasKey("ImageId"); b.ToTable("Image"); diff --git a/Backend/Migrations/20241115185046_init.cs b/Backend/Migrations/20241128201401_Initial.cs similarity index 93% rename from Backend/Migrations/20241115185046_init.cs rename to Backend/Migrations/20241128201401_Initial.cs index 311647c..9fe327c 100644 --- a/Backend/Migrations/20241115185046_init.cs +++ b/Backend/Migrations/20241128201401_Initial.cs @@ -7,7 +7,7 @@ namespace Backend.Migrations { /// - public partial class init : Migration + public partial class Initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -40,9 +40,9 @@ protected override void Up(MigrationBuilder migrationBuilder) { BidId = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ItemId = table.Column(type: "text", nullable: false), + ItemId = table.Column(type: "integer", nullable: false), BidderId = table.Column(type: "integer", nullable: false), - BidAmmount = table.Column(type: "integer", nullable: false), + BidAmount = table.Column(type: "integer", nullable: false), BidTime = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => @@ -104,8 +104,9 @@ protected override void Up(MigrationBuilder migrationBuilder) { ImageId = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ImageBlob = table.Column(type: "bytea", nullable: false), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false) + Data = table.Column(type: "bytea", nullable: false), + ContentType = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + AuctionWareId = table.Column(type: "integer", nullable: false) }, constraints: table => { diff --git a/Backend/Migrations/DatabaseContextModelSnapshot.cs b/Backend/Migrations/DatabaseContextModelSnapshot.cs index f25a121..0c035cc 100644 --- a/Backend/Migrations/DatabaseContextModelSnapshot.cs +++ b/Backend/Migrations/DatabaseContextModelSnapshot.cs @@ -16,12 +16,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("ProductVersion", "8.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("AuctionWare", b => + modelBuilder.Entity("Backend.Models.AuctionWare", b => { b.Property("ItemId") .ValueGeneratedOnAdd() @@ -76,7 +76,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("BidId")); - b.Property("BidAmmount") + b.Property("BidAmount") .HasColumnType("integer"); b.Property("BidTime") @@ -85,9 +85,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("BidderId") .HasColumnType("integer"); - b.Property("ItemId") - .IsRequired() - .HasColumnType("text"); + b.Property("ItemId") + .HasColumnType("integer"); b.HasKey("BidId"); @@ -185,6 +184,31 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Customer"); }); + modelBuilder.Entity("Image", b => + { + b.Property("ImageId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ImageId")); + + b.Property("AuctionWareId") + .HasColumnType("integer"); + + b.Property("ContentType") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Data") + .IsRequired() + .HasColumnType("bytea"); + + b.HasKey("ImageId"); + + b.ToTable("Image"); + }); + modelBuilder.Entity("Transaction", b => { b.Property("TransactionId") diff --git a/Frontend/src/services/imageService.ts b/Frontend/src/services/imageService.ts index 7bcc12b..af8c8ed 100644 --- a/Frontend/src/services/imageService.ts +++ b/Frontend/src/services/imageService.ts @@ -2,7 +2,7 @@ import axios from "axios"; import { CreatedAuctionResponse } from "./auctionService"; import { API_URL_BASE } from "./auctionService"; -const API_URL = API_URL_BASE + "image"; +const API_URL = API_URL_BASE + "api/image"; export const uploadImage = async ( file: File,