Compare commits

...

11 commits

Author SHA1 Message Date
Jiří Vrabec
13ab3083ed Fix update record author reference 2025-08-12 07:57:17 +02:00
Martin Velebil
cfa0da8082 Merge branch 'main' into 250811_ProductCompanyTable
# Conflicts:
#	DrinkRateAPI/Controllers/UserProfileController.cs
2025-08-12 06:52:40 +02:00
87a2250852 Handle unique constraint violation on ProductCompanyTableCouple create 2025-08-11 21:24:28 +02:00
e7b737a3dd Add error messages 2025-08-11 21:23:49 +02:00
69573991ca Add CompanyTableId to ProductTableGet 2025-08-11 21:22:37 +02:00
126e2a8c73 Merge remote-tracking branch 'origin/250809_UserProfile' into 250811_ProductCompanyTable 2025-08-11 21:14:11 +02:00
e3a1888146 Update namespace for ProductCompanyTableCouple 2025-08-11 21:04:28 +02:00
b7677bc139 Create product-company table coupling, fix one-to-one relationship
Introduce a new entity to couple product and company tables.
2025-08-11 21:03:28 +02:00
e0ecd86288 Establish a one-to-one relationship
Define a one-to-one relationship between CompanyTable and ProductTable.

Correct a typo in the CompanyTable DbSet name within the ApplicationDbContext to ensure correct database mapping and operations.
2025-08-11 20:12:42 +02:00
5401d29d44 Add product table management endpoints
Implement API endpoints for creating and retrieving product tables.
This allows administrators to define product tables and retrieve them by name.
The creation endpoint is secured and only accessible to administrators.
2025-08-11 19:47:34 +02:00
9ec9139f69 Enhance AdminOnly authorization policy
Refactor the AdminOnly authorization policy to handle cases where a user profile is not found.
Instead of throwing a NotFoundException, it now throws a ForbiddenException, ensuring a more appropriate response for unauthorized access attempts.
Also introduces PolicyConstants for policy names.
2025-08-11 19:47:12 +02:00
26 changed files with 4485 additions and 15 deletions

View file

@ -0,0 +1,7 @@
namespace DrinkRateAPI.ApiModels.ProductCompanyTableCouple;
public class ProductCompanyTableCouplePost
{
public string ProductTableName { get; set; }
public string CompanyTableName { get; set; }
}

View file

@ -0,0 +1,9 @@
namespace DrinkRateAPI.ApiModels.ProductCompanyTableCouple;
public class ProductCompanyTableCouplePostResponse
{
public string ProductTableName { get; set; }
public string ProductTableId { get; set; }
public string CompanyTableName { get; set; }
public string CompanyTableId { get; set; }
}

View file

@ -0,0 +1,8 @@
namespace DrinkRateAPI.ApiModels.ProductTable;
public class ProductTableGet
{
public string ProductTableName { get; set; }
public string ProductTableId { get; set; }
public string CompanyTableId { get; set; }
}

View file

@ -1,4 +1,5 @@
using DrinkRateAPI.DbEntities;
using DrinkRateAPI.Exceptions;
using DrinkRateAPI.Services;
namespace DrinkRateAPI.AuthorizationPolicies;
@ -26,7 +27,16 @@ public class AdminOnlyHandler : AuthorizationHandler<AdminOnlyRequirement>
AuthorizationHandlerContext context,
AdminOnlyRequirement requirement)
{
var userProfile = await _applicationUserService.UserProfileByApplicationUserAsync(context.User);
DbUserProfile userProfile;
try
{
userProfile = await _applicationUserService.UserProfileByApplicationUserAsync(context.User);
}
catch (NotFoundException _)
{
throw new ForbiddenException("You need to be logged in to do this action.");
}
if (_userProfileService.IsUserProfileAdmin(userProfile))
{

View file

@ -0,0 +1,7 @@
namespace DrinkRateAPI.AuthorizationPolicies;
public static class PolicyConstants
{
public const string AdminOnly = "AdminOnly";
}

View file

@ -9,7 +9,7 @@ public class ApplicationDbContext : IdentityDbContext<DbApplicationUser, Identit
{
public DbSet<DbCompany> Companies { get; set; }
public DbSet<DbCompanyRating> CompanyRatings { get; set; }
public DbSet<DbCompanyTable> CompanyTables { get; set; }
public DbSet<DbCompanyTable> CompanyTable { get; set; }
public DbSet<DbCompanyTableView> CompanyTableViews { get; set; }
public DbSet<DbProduct> Product { get; set; }
@ -85,6 +85,10 @@ public class ApplicationDbContext : IdentityDbContext<DbApplicationUser, Identit
entity.HasIndex(ct => ct.CompanyTableName)
.IsUnique();
entity.HasOne(ct => ct.ProductTable)
.WithOne(pt => pt.CompanyTable)
.HasForeignKey<DbProductTable>(pt => pt.CompanyTableId);
});
// Company Table View
@ -196,6 +200,10 @@ public class ApplicationDbContext : IdentityDbContext<DbApplicationUser, Identit
entity.HasOne(up => up.ApplicationUser)
.WithOne(au => au.UserProfile)
.HasForeignKey<DbUserProfile>(up => up.ApplicationUserId);
entity.HasMany(up => up.UpdateRecords)
.WithOne()
.HasForeignKey(ur => ur.UpdatedByUserProfileId);
});
// User Company Table Stat

View file

@ -0,0 +1,28 @@
using DrinkRateAPI.ApiModels.ProductCompanyTableCouple;
using DrinkRateAPI.AuthorizationPolicies;
using DrinkRateAPI.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace DrinkRateAPI.Controllers;
[ApiController]
[Route("productCompanyTableCouple")]
public class ProductCompanyTableCoupleController : ControllerBase
{
private ProductCompanyTableCoupleService _productCompanyTableCoupleService;
public ProductCompanyTableCoupleController(ProductCompanyTableCoupleService productCompanyTableCoupleService)
{
_productCompanyTableCoupleService = productCompanyTableCoupleService;
}
[HttpPost]
[Authorize(Policy = PolicyConstants.AdminOnly)]
[Produces("application/json")]
public async Task<ProductCompanyTableCouplePostResponse> PostProductCompanyTableCouple(
[FromBody] ProductCompanyTableCouplePost productCompanyTableCouple)
{
return await _productCompanyTableCoupleService.PostProductCompanyTableCoupleAsync(productCompanyTableCouple);
}
}

View file

@ -0,0 +1,28 @@
using DrinkRateAPI.ApiModels.ProductTable;
using DrinkRateAPI.AuthorizationPolicies;
using DrinkRateAPI.DbEntities;
using DrinkRateAPI.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace DrinkRateAPI.Controllers;
[ApiController]
[Route("productTable")]
public class ProductTableController : ControllerBase
{
private ProductTableService _productTableService;
public ProductTableController(ProductTableService productTableService)
{
_productTableService = productTableService;
}
[HttpGet("{productTableName}")]
[Produces("application/json")]
public async Task<ProductTableGet> GetProductTable([FromRoute] string productTableName)
{
return await _productTableService.GetProductTable(productTableName);
}
}

View file

@ -1,4 +1,5 @@
using DrinkRateAPI.ApiModels.UserProfile;
using DrinkRateAPI.AuthorizationPolicies;
using DrinkRateAPI.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@ -31,7 +32,7 @@ public class UserProfileController : ControllerBase
}
[HttpPut("{userId}")]
[Authorize(Policy = "AdminOnly")]
[Authorize(Policy = PolicyConstants.AdminOnly)]
[Produces("application/json")]
public async Task<UserProfileGet> PutUserProfile(string userId, [FromBody] UserProfilePut userProfile)
{
@ -39,7 +40,7 @@ public class UserProfileController : ControllerBase
}
[HttpGet("{userId}")]
[Authorize(Policy = "AdminOnly")]
[Authorize(Policy = PolicyConstants.AdminOnly)]
[Produces("application/json")]
public async Task<UserProfileGet> GetUserProfile(string userId)
{

View file

@ -7,4 +7,6 @@ public class DbCompanyTable
public ICollection<DbCompany> Companies { get; set; }
public string CompanyTableName { get; set; }
public DbProductTable ProductTable { get; set; }
}

View file

@ -7,4 +7,7 @@ public class DbProductTable
public ICollection<DbProduct> Products { get; set; }
public string ProductTableName { get; set; }
public Guid CompanyTableId { get; set; }
public DbCompanyTable CompanyTable { get; set; }
}

View file

@ -3,8 +3,7 @@ namespace DrinkRateAPI.DbEntities;
public class DbUpdateRecord
{
public Guid Id { get; set; }
public Guid UserProfileId { get; set; }
public DbUserProfile UserProfile { get; set; }
public Guid UpdatedByUserProfileId { get; set; }
public DateTime UpdateTime { get; set; }
public ICollection<DbUpdateRecordFieldChange> UpdateRecordFieldChanges { get; set; }
}

View file

@ -21,4 +21,6 @@ public class DbUserProfile : DbEntityWithHistory
public Guid ApplicationUserId { get; set; }
public virtual DbApplicationUser ApplicationUser { get; set; }
public ICollection<DbUpdateRecord> UpdateRecords { get; set; }
}

View file

@ -20,7 +20,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="ApiModels\" />
<Folder Include="Migrations\" />
</ItemGroup>

View file

@ -0,0 +1,974 @@
// <auto-generated />
using System;
using DrinkRateAPI.Contexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DrinkRateAPI.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20250811180050_ProductCompanyTableBinding")]
partial class ProductCompanyTableBinding
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b =>
{
b.Property<Guid>("CompanyTablesId")
.HasColumnType("uuid");
b.Property<Guid>("DbCompanyTableViewId")
.HasColumnType("uuid");
b.HasKey("CompanyTablesId", "DbCompanyTableViewId");
b.HasIndex("DbCompanyTableViewId");
b.ToTable("DbCompanyTableDbCompanyTableView");
});
modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{
b.Property<Guid>("CompanyTableViewsId")
.HasColumnType("uuid");
b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid");
b.HasKey("CompanyTableViewsId", "UserProfilesId");
b.HasIndex("UserProfilesId");
b.ToTable("DbCompanyTableViewDbUserProfile");
});
modelBuilder.Entity("DbProductTableDbProductTableView", b =>
{
b.Property<Guid>("DbProductTableViewId")
.HasColumnType("uuid");
b.Property<Guid>("ProductTablesId")
.HasColumnType("uuid");
b.HasKey("DbProductTableViewId", "ProductTablesId");
b.HasIndex("ProductTablesId");
b.ToTable("DbProductTableDbProductTableView");
});
modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{
b.Property<Guid>("ProductTableViewsId")
.HasColumnType("uuid");
b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid");
b.HasKey("ProductTableViewsId", "UserProfilesId");
b.HasIndex("UserProfilesId");
b.ToTable("DbProductTableViewDbUserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CompanyName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<long>("RatingCount")
.HasColumnType("bigint");
b.Property<long>("RatingSum")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("CompanyName")
.IsUnique();
b.HasIndex("CompanyTableId");
b.ToTable("Companies");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("CompanyId")
.HasColumnType("uuid");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte>("Rating")
.HasColumnType("smallint");
b.HasKey("UserProfileId", "CompanyId");
b.HasIndex("CompanyId");
b.ToTable("CompanyRatings");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTable", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CompanyTableName")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductTableId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("CompanyTableName")
.IsUnique();
b.ToTable("CompanyTables");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTableView", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("CompanyTableViews");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CompanyId")
.HasColumnType("uuid");
b.Property<string>("ProductName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("ProductTableId")
.HasColumnType("uuid");
b.Property<long>("RatingCount")
.HasColumnType("bigint");
b.Property<long>("RatingSum")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("CompanyId");
b.HasIndex("ProductName")
.IsUnique();
b.HasIndex("ProductTableId");
b.ToTable("Product");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte>("Rating")
.HasColumnType("smallint");
b.HasKey("UserProfileId", "ProductId");
b.HasIndex("ProductId");
b.ToTable("ProductRating");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<string>("ProductTableName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CompanyTableId")
.IsUnique();
b.HasIndex("ProductTableName")
.IsUnique();
b.ToTable("ProductTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTableView", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("ProductTableView");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyRatingCompanyId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyRatingUserProfileId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyTableViewId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductRatingProductId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductRatingUserProfileId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductTableViewId")
.HasColumnType("uuid");
b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DbCompanyId");
b.HasIndex("DbCompanyTableViewId");
b.HasIndex("DbProductId");
b.HasIndex("DbProductTableViewId");
b.HasIndex("UserProfileId");
b.HasIndex("DbCompanyRatingUserProfileId", "DbCompanyRatingCompanyId");
b.HasIndex("DbProductRatingUserProfileId", "DbProductRatingProductId");
b.ToTable("UpdateRecords");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecordFieldChange", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("DbUpdateRecordId")
.HasColumnType("uuid");
b.Property<string>("Field")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NewValue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OldValue")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DbUpdateRecordId");
b.ToTable("UpdateRecordFieldChanges");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ApplicationUserId")
.IsUnique();
b.HasIndex("UserName")
.IsUnique();
b.ToTable("UserProfiles");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<int>("Credits")
.HasColumnType("integer");
b.Property<int>("HighestRatingCount")
.HasColumnType("integer");
b.Property<int>("RatingCount")
.HasColumnType("integer");
b.HasKey("UserProfileId", "CompanyTableId");
b.HasIndex("CompanyTableId");
b.ToTable("UserProfileCompanyTableStats");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("ProductTableId")
.HasColumnType("uuid");
b.Property<int>("Credits")
.HasColumnType("integer");
b.Property<int>("HighestRatingCount")
.HasColumnType("integer");
b.Property<int>("RatingCount")
.HasColumnType("integer");
b.HasKey("UserProfileId", "ProductTableId");
b.HasIndex("ProductTableId");
b.ToTable("UserProfileProductTableStats");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", null)
.WithMany()
.HasForeignKey("CompanyTablesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany()
.HasForeignKey("DbCompanyTableViewId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany()
.HasForeignKey("CompanyTableViewsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany()
.HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbProductTableDbProductTableView", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany()
.HasForeignKey("DbProductTableViewId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", null)
.WithMany()
.HasForeignKey("ProductTablesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany()
.HasForeignKey("ProductTableViewsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany()
.HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithMany("Companies")
.HasForeignKey("CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", "Company")
.WithMany("CompanyRatings")
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("CompanyRatings")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", "Company")
.WithMany("Products")
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable")
.WithMany("Products")
.HasForeignKey("ProductTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("ProductTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProduct", "Product")
.WithMany("ProductRatings")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("ProductRatings")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithOne("ProductTable")
.HasForeignKey("DrinkRateAPI.DbEntities.DbProductTable", "CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", null)
.WithMany("History")
.HasForeignKey("DbCompanyId");
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany("History")
.HasForeignKey("DbCompanyTableViewId");
b.HasOne("DrinkRateAPI.DbEntities.DbProduct", null)
.WithMany("History")
.HasForeignKey("DbProductId");
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany("History")
.HasForeignKey("DbProductTableViewId");
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("History")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyRating", null)
.WithMany("History")
.HasForeignKey("DbCompanyRatingUserProfileId", "DbCompanyRatingCompanyId");
b.HasOne("DrinkRateAPI.DbEntities.DbProductRating", null)
.WithMany("History")
.HasForeignKey("DbProductRatingUserProfileId", "DbProductRatingProductId");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecordFieldChange", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbUpdateRecord", null)
.WithMany("UpdateRecordFieldChanges")
.HasForeignKey("DbUpdateRecordId");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", "ApplicationUser")
.WithOne("UserProfile")
.HasForeignKey("DrinkRateAPI.DbEntities.DbUserProfile", "ApplicationUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationUser");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithMany()
.HasForeignKey("CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserProfileCompanyTableStats")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable")
.WithMany()
.HasForeignKey("ProductTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserProfileProductTableStats")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ProductTable");
b.Navigation("UserProfile");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Navigation("UserProfile")
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.Navigation("CompanyRatings");
b.Navigation("History");
b.Navigation("Products");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTable", b =>
{
b.Navigation("Companies");
b.Navigation("ProductTable")
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTableView", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.Navigation("History");
b.Navigation("ProductRatings");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTableView", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.Navigation("UpdateRecordFieldChanges");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.Navigation("CompanyRatings");
b.Navigation("History");
b.Navigation("ProductRatings");
b.Navigation("UserProfileCompanyTableStats");
b.Navigation("UserProfileProductTableStats");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,63 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DrinkRateAPI.Migrations
{
/// <inheritdoc />
public partial class ProductCompanyTableBinding : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CompanyTableId",
table: "ProductTable",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "ProductTableId",
table: "CompanyTables",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.CreateIndex(
name: "IX_ProductTable_CompanyTableId",
table: "ProductTable",
column: "CompanyTableId",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_ProductTable_CompanyTables_CompanyTableId",
table: "ProductTable",
column: "CompanyTableId",
principalTable: "CompanyTables",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ProductTable_CompanyTables_CompanyTableId",
table: "ProductTable");
migrationBuilder.DropIndex(
name: "IX_ProductTable_CompanyTableId",
table: "ProductTable");
migrationBuilder.DropColumn(
name: "CompanyTableId",
table: "ProductTable");
migrationBuilder.DropColumn(
name: "ProductTableId",
table: "CompanyTables");
}
}
}

View file

@ -0,0 +1,974 @@
// <auto-generated />
using System;
using DrinkRateAPI.Contexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DrinkRateAPI.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20250811181117_FixTypo")]
partial class FixTypo
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b =>
{
b.Property<Guid>("CompanyTablesId")
.HasColumnType("uuid");
b.Property<Guid>("DbCompanyTableViewId")
.HasColumnType("uuid");
b.HasKey("CompanyTablesId", "DbCompanyTableViewId");
b.HasIndex("DbCompanyTableViewId");
b.ToTable("DbCompanyTableDbCompanyTableView");
});
modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{
b.Property<Guid>("CompanyTableViewsId")
.HasColumnType("uuid");
b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid");
b.HasKey("CompanyTableViewsId", "UserProfilesId");
b.HasIndex("UserProfilesId");
b.ToTable("DbCompanyTableViewDbUserProfile");
});
modelBuilder.Entity("DbProductTableDbProductTableView", b =>
{
b.Property<Guid>("DbProductTableViewId")
.HasColumnType("uuid");
b.Property<Guid>("ProductTablesId")
.HasColumnType("uuid");
b.HasKey("DbProductTableViewId", "ProductTablesId");
b.HasIndex("ProductTablesId");
b.ToTable("DbProductTableDbProductTableView");
});
modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{
b.Property<Guid>("ProductTableViewsId")
.HasColumnType("uuid");
b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid");
b.HasKey("ProductTableViewsId", "UserProfilesId");
b.HasIndex("UserProfilesId");
b.ToTable("DbProductTableViewDbUserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CompanyName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<long>("RatingCount")
.HasColumnType("bigint");
b.Property<long>("RatingSum")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("CompanyName")
.IsUnique();
b.HasIndex("CompanyTableId");
b.ToTable("Companies");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("CompanyId")
.HasColumnType("uuid");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte>("Rating")
.HasColumnType("smallint");
b.HasKey("UserProfileId", "CompanyId");
b.HasIndex("CompanyId");
b.ToTable("CompanyRatings");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTable", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CompanyTableName")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductTableId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("CompanyTableName")
.IsUnique();
b.ToTable("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTableView", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("CompanyTableViews");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CompanyId")
.HasColumnType("uuid");
b.Property<string>("ProductName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("ProductTableId")
.HasColumnType("uuid");
b.Property<long>("RatingCount")
.HasColumnType("bigint");
b.Property<long>("RatingSum")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("CompanyId");
b.HasIndex("ProductName")
.IsUnique();
b.HasIndex("ProductTableId");
b.ToTable("Product");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte>("Rating")
.HasColumnType("smallint");
b.HasKey("UserProfileId", "ProductId");
b.HasIndex("ProductId");
b.ToTable("ProductRating");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<string>("ProductTableName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CompanyTableId")
.IsUnique();
b.HasIndex("ProductTableName")
.IsUnique();
b.ToTable("ProductTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTableView", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("ProductTableView");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyRatingCompanyId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyRatingUserProfileId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyTableViewId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductRatingProductId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductRatingUserProfileId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductTableViewId")
.HasColumnType("uuid");
b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DbCompanyId");
b.HasIndex("DbCompanyTableViewId");
b.HasIndex("DbProductId");
b.HasIndex("DbProductTableViewId");
b.HasIndex("UserProfileId");
b.HasIndex("DbCompanyRatingUserProfileId", "DbCompanyRatingCompanyId");
b.HasIndex("DbProductRatingUserProfileId", "DbProductRatingProductId");
b.ToTable("UpdateRecords");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecordFieldChange", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("DbUpdateRecordId")
.HasColumnType("uuid");
b.Property<string>("Field")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NewValue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OldValue")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DbUpdateRecordId");
b.ToTable("UpdateRecordFieldChanges");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ApplicationUserId")
.IsUnique();
b.HasIndex("UserName")
.IsUnique();
b.ToTable("UserProfiles");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<int>("Credits")
.HasColumnType("integer");
b.Property<int>("HighestRatingCount")
.HasColumnType("integer");
b.Property<int>("RatingCount")
.HasColumnType("integer");
b.HasKey("UserProfileId", "CompanyTableId");
b.HasIndex("CompanyTableId");
b.ToTable("UserProfileCompanyTableStats");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("ProductTableId")
.HasColumnType("uuid");
b.Property<int>("Credits")
.HasColumnType("integer");
b.Property<int>("HighestRatingCount")
.HasColumnType("integer");
b.Property<int>("RatingCount")
.HasColumnType("integer");
b.HasKey("UserProfileId", "ProductTableId");
b.HasIndex("ProductTableId");
b.ToTable("UserProfileProductTableStats");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", null)
.WithMany()
.HasForeignKey("CompanyTablesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany()
.HasForeignKey("DbCompanyTableViewId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany()
.HasForeignKey("CompanyTableViewsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany()
.HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbProductTableDbProductTableView", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany()
.HasForeignKey("DbProductTableViewId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", null)
.WithMany()
.HasForeignKey("ProductTablesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany()
.HasForeignKey("ProductTableViewsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany()
.HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithMany("Companies")
.HasForeignKey("CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", "Company")
.WithMany("CompanyRatings")
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("CompanyRatings")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", "Company")
.WithMany("Products")
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable")
.WithMany("Products")
.HasForeignKey("ProductTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("ProductTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProduct", "Product")
.WithMany("ProductRatings")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("ProductRatings")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithOne("ProductTable")
.HasForeignKey("DrinkRateAPI.DbEntities.DbProductTable", "CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", null)
.WithMany("History")
.HasForeignKey("DbCompanyId");
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany("History")
.HasForeignKey("DbCompanyTableViewId");
b.HasOne("DrinkRateAPI.DbEntities.DbProduct", null)
.WithMany("History")
.HasForeignKey("DbProductId");
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany("History")
.HasForeignKey("DbProductTableViewId");
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("History")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyRating", null)
.WithMany("History")
.HasForeignKey("DbCompanyRatingUserProfileId", "DbCompanyRatingCompanyId");
b.HasOne("DrinkRateAPI.DbEntities.DbProductRating", null)
.WithMany("History")
.HasForeignKey("DbProductRatingUserProfileId", "DbProductRatingProductId");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecordFieldChange", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbUpdateRecord", null)
.WithMany("UpdateRecordFieldChanges")
.HasForeignKey("DbUpdateRecordId");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", "ApplicationUser")
.WithOne("UserProfile")
.HasForeignKey("DrinkRateAPI.DbEntities.DbUserProfile", "ApplicationUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationUser");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithMany()
.HasForeignKey("CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserProfileCompanyTableStats")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable")
.WithMany()
.HasForeignKey("ProductTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserProfileProductTableStats")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ProductTable");
b.Navigation("UserProfile");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Navigation("UserProfile")
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.Navigation("CompanyRatings");
b.Navigation("History");
b.Navigation("Products");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTable", b =>
{
b.Navigation("Companies");
b.Navigation("ProductTable")
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTableView", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.Navigation("History");
b.Navigation("ProductRatings");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTableView", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.Navigation("UpdateRecordFieldChanges");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.Navigation("CompanyRatings");
b.Navigation("History");
b.Navigation("ProductRatings");
b.Navigation("UserProfileCompanyTableStats");
b.Navigation("UserProfileProductTableStats");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,150 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DrinkRateAPI.Migrations
{
/// <inheritdoc />
public partial class FixTypo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Companies_CompanyTables_CompanyTableId",
table: "Companies");
migrationBuilder.DropForeignKey(
name: "FK_DbCompanyTableDbCompanyTableView_CompanyTables_CompanyTable~",
table: "DbCompanyTableDbCompanyTableView");
migrationBuilder.DropForeignKey(
name: "FK_ProductTable_CompanyTables_CompanyTableId",
table: "ProductTable");
migrationBuilder.DropForeignKey(
name: "FK_UserProfileCompanyTableStats_CompanyTables_CompanyTableId",
table: "UserProfileCompanyTableStats");
migrationBuilder.DropPrimaryKey(
name: "PK_CompanyTables",
table: "CompanyTables");
migrationBuilder.RenameTable(
name: "CompanyTables",
newName: "CompanyTable");
migrationBuilder.RenameIndex(
name: "IX_CompanyTables_CompanyTableName",
table: "CompanyTable",
newName: "IX_CompanyTable_CompanyTableName");
migrationBuilder.AddPrimaryKey(
name: "PK_CompanyTable",
table: "CompanyTable",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Companies_CompanyTable_CompanyTableId",
table: "Companies",
column: "CompanyTableId",
principalTable: "CompanyTable",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_DbCompanyTableDbCompanyTableView_CompanyTable_CompanyTables~",
table: "DbCompanyTableDbCompanyTableView",
column: "CompanyTablesId",
principalTable: "CompanyTable",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ProductTable_CompanyTable_CompanyTableId",
table: "ProductTable",
column: "CompanyTableId",
principalTable: "CompanyTable",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UserProfileCompanyTableStats_CompanyTable_CompanyTableId",
table: "UserProfileCompanyTableStats",
column: "CompanyTableId",
principalTable: "CompanyTable",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Companies_CompanyTable_CompanyTableId",
table: "Companies");
migrationBuilder.DropForeignKey(
name: "FK_DbCompanyTableDbCompanyTableView_CompanyTable_CompanyTables~",
table: "DbCompanyTableDbCompanyTableView");
migrationBuilder.DropForeignKey(
name: "FK_ProductTable_CompanyTable_CompanyTableId",
table: "ProductTable");
migrationBuilder.DropForeignKey(
name: "FK_UserProfileCompanyTableStats_CompanyTable_CompanyTableId",
table: "UserProfileCompanyTableStats");
migrationBuilder.DropPrimaryKey(
name: "PK_CompanyTable",
table: "CompanyTable");
migrationBuilder.RenameTable(
name: "CompanyTable",
newName: "CompanyTables");
migrationBuilder.RenameIndex(
name: "IX_CompanyTable_CompanyTableName",
table: "CompanyTables",
newName: "IX_CompanyTables_CompanyTableName");
migrationBuilder.AddPrimaryKey(
name: "PK_CompanyTables",
table: "CompanyTables",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Companies_CompanyTables_CompanyTableId",
table: "Companies",
column: "CompanyTableId",
principalTable: "CompanyTables",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_DbCompanyTableDbCompanyTableView_CompanyTables_CompanyTable~",
table: "DbCompanyTableDbCompanyTableView",
column: "CompanyTablesId",
principalTable: "CompanyTables",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ProductTable_CompanyTables_CompanyTableId",
table: "ProductTable",
column: "CompanyTableId",
principalTable: "CompanyTables",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UserProfileCompanyTableStats_CompanyTables_CompanyTableId",
table: "UserProfileCompanyTableStats",
column: "CompanyTableId",
principalTable: "CompanyTables",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View file

@ -0,0 +1,971 @@
// <auto-generated />
using System;
using DrinkRateAPI.Contexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DrinkRateAPI.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20250811190023_FixProductCompanyTableBinding")]
partial class FixProductCompanyTableBinding
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b =>
{
b.Property<Guid>("CompanyTablesId")
.HasColumnType("uuid");
b.Property<Guid>("DbCompanyTableViewId")
.HasColumnType("uuid");
b.HasKey("CompanyTablesId", "DbCompanyTableViewId");
b.HasIndex("DbCompanyTableViewId");
b.ToTable("DbCompanyTableDbCompanyTableView");
});
modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{
b.Property<Guid>("CompanyTableViewsId")
.HasColumnType("uuid");
b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid");
b.HasKey("CompanyTableViewsId", "UserProfilesId");
b.HasIndex("UserProfilesId");
b.ToTable("DbCompanyTableViewDbUserProfile");
});
modelBuilder.Entity("DbProductTableDbProductTableView", b =>
{
b.Property<Guid>("DbProductTableViewId")
.HasColumnType("uuid");
b.Property<Guid>("ProductTablesId")
.HasColumnType("uuid");
b.HasKey("DbProductTableViewId", "ProductTablesId");
b.HasIndex("ProductTablesId");
b.ToTable("DbProductTableDbProductTableView");
});
modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{
b.Property<Guid>("ProductTableViewsId")
.HasColumnType("uuid");
b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid");
b.HasKey("ProductTableViewsId", "UserProfilesId");
b.HasIndex("UserProfilesId");
b.ToTable("DbProductTableViewDbUserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CompanyName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<long>("RatingCount")
.HasColumnType("bigint");
b.Property<long>("RatingSum")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("CompanyName")
.IsUnique();
b.HasIndex("CompanyTableId");
b.ToTable("Companies");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("CompanyId")
.HasColumnType("uuid");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte>("Rating")
.HasColumnType("smallint");
b.HasKey("UserProfileId", "CompanyId");
b.HasIndex("CompanyId");
b.ToTable("CompanyRatings");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTable", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CompanyTableName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CompanyTableName")
.IsUnique();
b.ToTable("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTableView", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("CompanyTableViews");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CompanyId")
.HasColumnType("uuid");
b.Property<string>("ProductName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("ProductTableId")
.HasColumnType("uuid");
b.Property<long>("RatingCount")
.HasColumnType("bigint");
b.Property<long>("RatingSum")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("CompanyId");
b.HasIndex("ProductName")
.IsUnique();
b.HasIndex("ProductTableId");
b.ToTable("Product");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte>("Rating")
.HasColumnType("smallint");
b.HasKey("UserProfileId", "ProductId");
b.HasIndex("ProductId");
b.ToTable("ProductRating");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<string>("ProductTableName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CompanyTableId")
.IsUnique();
b.HasIndex("ProductTableName")
.IsUnique();
b.ToTable("ProductTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTableView", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("ProductTableView");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyRatingCompanyId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyRatingUserProfileId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyTableViewId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductRatingProductId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductRatingUserProfileId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductTableViewId")
.HasColumnType("uuid");
b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DbCompanyId");
b.HasIndex("DbCompanyTableViewId");
b.HasIndex("DbProductId");
b.HasIndex("DbProductTableViewId");
b.HasIndex("UserProfileId");
b.HasIndex("DbCompanyRatingUserProfileId", "DbCompanyRatingCompanyId");
b.HasIndex("DbProductRatingUserProfileId", "DbProductRatingProductId");
b.ToTable("UpdateRecords");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecordFieldChange", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("DbUpdateRecordId")
.HasColumnType("uuid");
b.Property<string>("Field")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NewValue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OldValue")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DbUpdateRecordId");
b.ToTable("UpdateRecordFieldChanges");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ApplicationUserId")
.IsUnique();
b.HasIndex("UserName")
.IsUnique();
b.ToTable("UserProfiles");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<int>("Credits")
.HasColumnType("integer");
b.Property<int>("HighestRatingCount")
.HasColumnType("integer");
b.Property<int>("RatingCount")
.HasColumnType("integer");
b.HasKey("UserProfileId", "CompanyTableId");
b.HasIndex("CompanyTableId");
b.ToTable("UserProfileCompanyTableStats");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("ProductTableId")
.HasColumnType("uuid");
b.Property<int>("Credits")
.HasColumnType("integer");
b.Property<int>("HighestRatingCount")
.HasColumnType("integer");
b.Property<int>("RatingCount")
.HasColumnType("integer");
b.HasKey("UserProfileId", "ProductTableId");
b.HasIndex("ProductTableId");
b.ToTable("UserProfileProductTableStats");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", null)
.WithMany()
.HasForeignKey("CompanyTablesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany()
.HasForeignKey("DbCompanyTableViewId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany()
.HasForeignKey("CompanyTableViewsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany()
.HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbProductTableDbProductTableView", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany()
.HasForeignKey("DbProductTableViewId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", null)
.WithMany()
.HasForeignKey("ProductTablesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany()
.HasForeignKey("ProductTableViewsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany()
.HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithMany("Companies")
.HasForeignKey("CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", "Company")
.WithMany("CompanyRatings")
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("CompanyRatings")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", "Company")
.WithMany("Products")
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable")
.WithMany("Products")
.HasForeignKey("ProductTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("ProductTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProduct", "Product")
.WithMany("ProductRatings")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("ProductRatings")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithOne("ProductTable")
.HasForeignKey("DrinkRateAPI.DbEntities.DbProductTable", "CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", null)
.WithMany("History")
.HasForeignKey("DbCompanyId");
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany("History")
.HasForeignKey("DbCompanyTableViewId");
b.HasOne("DrinkRateAPI.DbEntities.DbProduct", null)
.WithMany("History")
.HasForeignKey("DbProductId");
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany("History")
.HasForeignKey("DbProductTableViewId");
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("History")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyRating", null)
.WithMany("History")
.HasForeignKey("DbCompanyRatingUserProfileId", "DbCompanyRatingCompanyId");
b.HasOne("DrinkRateAPI.DbEntities.DbProductRating", null)
.WithMany("History")
.HasForeignKey("DbProductRatingUserProfileId", "DbProductRatingProductId");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecordFieldChange", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbUpdateRecord", null)
.WithMany("UpdateRecordFieldChanges")
.HasForeignKey("DbUpdateRecordId");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", "ApplicationUser")
.WithOne("UserProfile")
.HasForeignKey("DrinkRateAPI.DbEntities.DbUserProfile", "ApplicationUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationUser");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithMany()
.HasForeignKey("CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserProfileCompanyTableStats")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable")
.WithMany()
.HasForeignKey("ProductTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserProfileProductTableStats")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ProductTable");
b.Navigation("UserProfile");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Navigation("UserProfile")
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.Navigation("CompanyRatings");
b.Navigation("History");
b.Navigation("Products");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTable", b =>
{
b.Navigation("Companies");
b.Navigation("ProductTable")
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTableView", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.Navigation("History");
b.Navigation("ProductRatings");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTableView", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.Navigation("UpdateRecordFieldChanges");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.Navigation("CompanyRatings");
b.Navigation("History");
b.Navigation("ProductRatings");
b.Navigation("UserProfileCompanyTableStats");
b.Navigation("UserProfileProductTableStats");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,30 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DrinkRateAPI.Migrations
{
/// <inheritdoc />
public partial class FixProductCompanyTableBinding : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ProductTableId",
table: "CompanyTable");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "ProductTableId",
table: "CompanyTable",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
}
}
}

View file

@ -0,0 +1,980 @@
// <auto-generated />
using System;
using DrinkRateAPI.Contexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DrinkRateAPI.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20250812055359_HistoryUpdatedByField")]
partial class HistoryUpdatedByField
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b =>
{
b.Property<Guid>("CompanyTablesId")
.HasColumnType("uuid");
b.Property<Guid>("DbCompanyTableViewId")
.HasColumnType("uuid");
b.HasKey("CompanyTablesId", "DbCompanyTableViewId");
b.HasIndex("DbCompanyTableViewId");
b.ToTable("DbCompanyTableDbCompanyTableView");
});
modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{
b.Property<Guid>("CompanyTableViewsId")
.HasColumnType("uuid");
b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid");
b.HasKey("CompanyTableViewsId", "UserProfilesId");
b.HasIndex("UserProfilesId");
b.ToTable("DbCompanyTableViewDbUserProfile");
});
modelBuilder.Entity("DbProductTableDbProductTableView", b =>
{
b.Property<Guid>("DbProductTableViewId")
.HasColumnType("uuid");
b.Property<Guid>("ProductTablesId")
.HasColumnType("uuid");
b.HasKey("DbProductTableViewId", "ProductTablesId");
b.HasIndex("ProductTablesId");
b.ToTable("DbProductTableDbProductTableView");
});
modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{
b.Property<Guid>("ProductTableViewsId")
.HasColumnType("uuid");
b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid");
b.HasKey("ProductTableViewsId", "UserProfilesId");
b.HasIndex("UserProfilesId");
b.ToTable("DbProductTableViewDbUserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CompanyName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<long>("RatingCount")
.HasColumnType("bigint");
b.Property<long>("RatingSum")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("CompanyName")
.IsUnique();
b.HasIndex("CompanyTableId");
b.ToTable("Companies");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("CompanyId")
.HasColumnType("uuid");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte>("Rating")
.HasColumnType("smallint");
b.HasKey("UserProfileId", "CompanyId");
b.HasIndex("CompanyId");
b.ToTable("CompanyRatings");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTable", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CompanyTableName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CompanyTableName")
.IsUnique();
b.ToTable("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTableView", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("CompanyTableViews");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CompanyId")
.HasColumnType("uuid");
b.Property<string>("ProductName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("ProductTableId")
.HasColumnType("uuid");
b.Property<long>("RatingCount")
.HasColumnType("bigint");
b.Property<long>("RatingSum")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("CompanyId");
b.HasIndex("ProductName")
.IsUnique();
b.HasIndex("ProductTableId");
b.ToTable("Product");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte>("Rating")
.HasColumnType("smallint");
b.HasKey("UserProfileId", "ProductId");
b.HasIndex("ProductId");
b.ToTable("ProductRating");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<string>("ProductTableName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CompanyTableId")
.IsUnique();
b.HasIndex("ProductTableName")
.IsUnique();
b.ToTable("ProductTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTableView", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("ProductTableView");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyRatingCompanyId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyRatingUserProfileId")
.HasColumnType("uuid");
b.Property<Guid?>("DbCompanyTableViewId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductRatingProductId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductRatingUserProfileId")
.HasColumnType("uuid");
b.Property<Guid?>("DbProductTableViewId")
.HasColumnType("uuid");
b.Property<Guid?>("DbUserProfileId")
.HasColumnType("uuid");
b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("UpdatedByUserProfileId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DbCompanyId");
b.HasIndex("DbCompanyTableViewId");
b.HasIndex("DbProductId");
b.HasIndex("DbProductTableViewId");
b.HasIndex("DbUserProfileId");
b.HasIndex("UpdatedByUserProfileId");
b.HasIndex("DbCompanyRatingUserProfileId", "DbCompanyRatingCompanyId");
b.HasIndex("DbProductRatingUserProfileId", "DbProductRatingProductId");
b.ToTable("UpdateRecords");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecordFieldChange", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("DbUpdateRecordId")
.HasColumnType("uuid");
b.Property<string>("Field")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NewValue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OldValue")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DbUpdateRecordId");
b.ToTable("UpdateRecordFieldChanges");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ApplicationUserId")
.IsUnique();
b.HasIndex("UserName")
.IsUnique();
b.ToTable("UserProfiles");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<int>("Credits")
.HasColumnType("integer");
b.Property<int>("HighestRatingCount")
.HasColumnType("integer");
b.Property<int>("RatingCount")
.HasColumnType("integer");
b.HasKey("UserProfileId", "CompanyTableId");
b.HasIndex("CompanyTableId");
b.ToTable("UserProfileCompanyTableStats");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("ProductTableId")
.HasColumnType("uuid");
b.Property<int>("Credits")
.HasColumnType("integer");
b.Property<int>("HighestRatingCount")
.HasColumnType("integer");
b.Property<int>("RatingCount")
.HasColumnType("integer");
b.HasKey("UserProfileId", "ProductTableId");
b.HasIndex("ProductTableId");
b.ToTable("UserProfileProductTableStats");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", null)
.WithMany()
.HasForeignKey("CompanyTablesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany()
.HasForeignKey("DbCompanyTableViewId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany()
.HasForeignKey("CompanyTableViewsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany()
.HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbProductTableDbProductTableView", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany()
.HasForeignKey("DbProductTableViewId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", null)
.WithMany()
.HasForeignKey("ProductTablesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany()
.HasForeignKey("ProductTableViewsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany()
.HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithMany("Companies")
.HasForeignKey("CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", "Company")
.WithMany("CompanyRatings")
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("CompanyRatings")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", "Company")
.WithMany("Products")
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable")
.WithMany("Products")
.HasForeignKey("ProductTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("ProductTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProduct", "Product")
.WithMany("ProductRatings")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("ProductRatings")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithOne("ProductTable")
.HasForeignKey("DrinkRateAPI.DbEntities.DbProductTable", "CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", null)
.WithMany("History")
.HasForeignKey("DbCompanyId");
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany("History")
.HasForeignKey("DbCompanyTableViewId");
b.HasOne("DrinkRateAPI.DbEntities.DbProduct", null)
.WithMany("History")
.HasForeignKey("DbProductId");
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany("History")
.HasForeignKey("DbProductTableViewId");
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany("History")
.HasForeignKey("DbUserProfileId");
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany("UpdateRecords")
.HasForeignKey("UpdatedByUserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyRating", null)
.WithMany("History")
.HasForeignKey("DbCompanyRatingUserProfileId", "DbCompanyRatingCompanyId");
b.HasOne("DrinkRateAPI.DbEntities.DbProductRating", null)
.WithMany("History")
.HasForeignKey("DbProductRatingUserProfileId", "DbProductRatingProductId");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecordFieldChange", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbUpdateRecord", null)
.WithMany("UpdateRecordFieldChanges")
.HasForeignKey("DbUpdateRecordId");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", "ApplicationUser")
.WithOne("UserProfile")
.HasForeignKey("DrinkRateAPI.DbEntities.DbUserProfile", "ApplicationUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationUser");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithMany()
.HasForeignKey("CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserProfileCompanyTableStats")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable")
.WithMany()
.HasForeignKey("ProductTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserProfileProductTableStats")
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ProductTable");
b.Navigation("UserProfile");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Navigation("UserProfile")
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
{
b.Navigation("CompanyRatings");
b.Navigation("History");
b.Navigation("Products");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTable", b =>
{
b.Navigation("Companies");
b.Navigation("ProductTable")
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTableView", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
{
b.Navigation("History");
b.Navigation("ProductRatings");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTableView", b =>
{
b.Navigation("History");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.Navigation("UpdateRecordFieldChanges");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{
b.Navigation("CompanyRatings");
b.Navigation("History");
b.Navigation("ProductRatings");
b.Navigation("UpdateRecords");
b.Navigation("UserProfileCompanyTableStats");
b.Navigation("UserProfileProductTableStats");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,93 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DrinkRateAPI.Migrations
{
/// <inheritdoc />
public partial class HistoryUpdatedByField : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_UpdateRecords_UserProfiles_UserProfileId",
table: "UpdateRecords");
migrationBuilder.RenameColumn(
name: "UserProfileId",
table: "UpdateRecords",
newName: "UpdatedByUserProfileId");
migrationBuilder.RenameIndex(
name: "IX_UpdateRecords_UserProfileId",
table: "UpdateRecords",
newName: "IX_UpdateRecords_UpdatedByUserProfileId");
migrationBuilder.AddColumn<Guid>(
name: "DbUserProfileId",
table: "UpdateRecords",
type: "uuid",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_UpdateRecords_DbUserProfileId",
table: "UpdateRecords",
column: "DbUserProfileId");
migrationBuilder.AddForeignKey(
name: "FK_UpdateRecords_UserProfiles_DbUserProfileId",
table: "UpdateRecords",
column: "DbUserProfileId",
principalTable: "UserProfiles",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_UpdateRecords_UserProfiles_UpdatedByUserProfileId",
table: "UpdateRecords",
column: "UpdatedByUserProfileId",
principalTable: "UserProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_UpdateRecords_UserProfiles_DbUserProfileId",
table: "UpdateRecords");
migrationBuilder.DropForeignKey(
name: "FK_UpdateRecords_UserProfiles_UpdatedByUserProfileId",
table: "UpdateRecords");
migrationBuilder.DropIndex(
name: "IX_UpdateRecords_DbUserProfileId",
table: "UpdateRecords");
migrationBuilder.DropColumn(
name: "DbUserProfileId",
table: "UpdateRecords");
migrationBuilder.RenameColumn(
name: "UpdatedByUserProfileId",
table: "UpdateRecords",
newName: "UserProfileId");
migrationBuilder.RenameIndex(
name: "IX_UpdateRecords_UpdatedByUserProfileId",
table: "UpdateRecords",
newName: "IX_UpdateRecords_UserProfileId");
migrationBuilder.AddForeignKey(
name: "FK_UpdateRecords_UserProfiles_UserProfileId",
table: "UpdateRecords",
column: "UserProfileId",
principalTable: "UserProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View file

@ -213,7 +213,7 @@ namespace DrinkRateAPI.Migrations
b.HasIndex("CompanyTableName")
.IsUnique();
b.ToTable("CompanyTables");
b.ToTable("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTableView", b =>
@ -289,12 +289,18 @@ namespace DrinkRateAPI.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CompanyTableId")
.HasColumnType("uuid");
b.Property<string>("ProductTableName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CompanyTableId")
.IsUnique();
b.HasIndex("ProductTableName")
.IsUnique();
@ -342,10 +348,13 @@ namespace DrinkRateAPI.Migrations
b.Property<Guid?>("DbProductTableViewId")
.HasColumnType("uuid");
b.Property<Guid?>("DbUserProfileId")
.HasColumnType("uuid");
b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("UserProfileId")
b.Property<Guid>("UpdatedByUserProfileId")
.HasColumnType("uuid");
b.HasKey("Id");
@ -358,7 +367,9 @@ namespace DrinkRateAPI.Migrations
b.HasIndex("DbProductTableViewId");
b.HasIndex("UserProfileId");
b.HasIndex("DbUserProfileId");
b.HasIndex("UpdatedByUserProfileId");
b.HasIndex("DbCompanyRatingUserProfileId", "DbCompanyRatingCompanyId");
@ -731,6 +742,17 @@ namespace DrinkRateAPI.Migrations
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductTable", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithOne("ProductTable")
.HasForeignKey("DrinkRateAPI.DbEntities.DbProductTable", "CompanyTableId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CompanyTable");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecord", b =>
{
b.HasOne("DrinkRateAPI.DbEntities.DbCompany", null)
@ -749,9 +771,13 @@ namespace DrinkRateAPI.Migrations
.WithMany("History")
.HasForeignKey("DbProductTableViewId");
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany("History")
.HasForeignKey("UserProfileId")
.HasForeignKey("DbUserProfileId");
b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany("UpdateRecords")
.HasForeignKey("UpdatedByUserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -762,8 +788,6 @@ namespace DrinkRateAPI.Migrations
b.HasOne("DrinkRateAPI.DbEntities.DbProductRating", null)
.WithMany("History")
.HasForeignKey("DbProductRatingUserProfileId", "DbProductRatingProductId");
b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUpdateRecordFieldChange", b =>
@ -896,6 +920,9 @@ namespace DrinkRateAPI.Migrations
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTable", b =>
{
b.Navigation("Companies");
b.Navigation("ProductTable")
.IsRequired();
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyTableView", b =>
@ -938,6 +965,8 @@ namespace DrinkRateAPI.Migrations
b.Navigation("ProductRatings");
b.Navigation("UpdateRecords");
b.Navigation("UserProfileCompanyTableStats");
b.Navigation("UserProfileProductTableStats");

View file

@ -15,7 +15,7 @@ builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddAuthorizationBuilder()
.AddPolicy("AdminOnly", policy =>
.AddPolicy(PolicyConstants.AdminOnly, policy =>
policy.Requirements.Add(new AdminOnlyRequirement()));
builder.Services.AddIdentityApiEndpoints<DbApplicationUser>()
.AddEntityFrameworkStores<ApplicationDbContext>();
@ -58,6 +58,8 @@ builder.Services.AddSwaggerGen(c =>
builder.Services.AddDbContext<ApplicationDbContext>();
builder.Services.AddScoped<ApplicationUserService>();
builder.Services.AddScoped<UserProfileService>();
builder.Services.AddScoped<ProductTableService>();
builder.Services.AddScoped<ProductCompanyTableCoupleService>();
var app = builder.Build();

View file

@ -0,0 +1,66 @@
using DrinkRateAPI.ApiModels.ProductCompanyTableCouple;
using DrinkRateAPI.ApiModels.ProductTable;
using DrinkRateAPI.Contexts;
using DrinkRateAPI.DbEntities;
using DrinkRateAPI.Exceptions;
using Microsoft.EntityFrameworkCore;
using Npgsql;
namespace DrinkRateAPI.Services;
public class ProductCompanyTableCoupleService(ApplicationDbContext context)
{
private ApplicationDbContext _context = context;
public async Task<ProductCompanyTableCouplePostResponse> PostProductCompanyTableCoupleAsync(
ProductCompanyTableCouplePost productCompanyTableCouplePost)
{
var companyTable = new DbCompanyTable
{
CompanyTableName = productCompanyTableCouplePost.CompanyTableName,
ProductTable = new DbProductTable
{
ProductTableName = productCompanyTableCouplePost.ProductTableName
}
};
_context.CompanyTable.Add(companyTable);
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateException ex) when
(ex.InnerException is PostgresException
{
SqlState: PostgresErrorCodes.UniqueViolation
}
)
{
throw new BadRequestException("Product table or company table with the same name already exists.");
}
return await GetProductCompanyTableCouplePostResponse(
productCompanyTableCouplePost.ProductTableName,
productCompanyTableCouplePost.CompanyTableName);
}
private async Task<ProductCompanyTableCouplePostResponse> GetProductCompanyTableCouplePostResponse(
string productTableName, string companyTableName)
{
var productTable =
await _context.ProductTable.FirstOrDefaultAsync(x => x.ProductTableName == productTableName) ??
throw new NotFoundException();
var companyTable =
await _context.CompanyTable.FirstOrDefaultAsync(x => x.CompanyTableName == companyTableName) ??
throw new NotFoundException();
return new ProductCompanyTableCouplePostResponse
{
ProductTableName = productTable.ProductTableName,
ProductTableId = productTable.Id.ToString(),
CompanyTableName = companyTable.CompanyTableName,
CompanyTableId = companyTable.Id.ToString()
};
}
}

View file

@ -0,0 +1,27 @@
using DrinkRateAPI.ApiModels.ProductTable;
using DrinkRateAPI.Contexts;
using DrinkRateAPI.DbEntities;
using DrinkRateAPI.Exceptions;
using Microsoft.EntityFrameworkCore;
namespace DrinkRateAPI.Services;
public class ProductTableService(ApplicationDbContext context)
{
private ApplicationDbContext _context = context;
public async Task<ProductTableGet> GetProductTable(string productTableName)
{
var productTable =
await _context.ProductTable.FirstOrDefaultAsync(x => x.ProductTableName == productTableName) ??
throw new NotFoundException($"Product table with the name {productTableName} not found.");
return new ProductTableGet
{
ProductTableName = productTable.ProductTableName,
ProductTableId = productTable.Id.ToString(),
CompanyTableId = productTable.CompanyTableId.ToString(),
};
}
}