Connect UserProfile with ApplicationUser

Establishes a link between DbUserProfile and DbApplicationUser,
allowing for better management of user-related information
and integration with ASP.NET Identity.

Renames DbUser to DbUserProfile and updates related entities and configurations.
This commit is contained in:
martinshoob 2025-08-09 15:43:32 +02:00
parent e6ed0d1b37
commit 786f83bf2d
16 changed files with 416 additions and 250 deletions

View file

@ -15,9 +15,11 @@ public class ApplicationDbContext : DbContext
public DbSet<DbProductTable> ProductTable { get; set; } public DbSet<DbProductTable> ProductTable { get; set; }
public DbSet<DbProductTableView> ProductTableView { get; set; } public DbSet<DbProductTableView> ProductTableView { get; set; }
public DbSet<DbUser> Users { get; set; } public DbSet<DbUserProfile> UserProfiles { get; set; }
public DbSet<DbUserCompanyTableStat> UserCompanyTableStats { get; set; } public DbSet<DbUserProfileCompanyTableStat> UserProfileCompanyTableStats { get; set; }
public DbSet<DbUserProductTableStat> UserProductTableStats { get; set; } public DbSet<DbUserProfileProductTableStat> UserProfileProductTableStats { get; set; }
public DbSet<DbApplicationUser> ApplicationUsers { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
@ -58,10 +60,10 @@ public class ApplicationDbContext : DbContext
// Company Rating // Company Rating
modelBuilder.Entity<DbCompanyRating>(entity => modelBuilder.Entity<DbCompanyRating>(entity =>
{ {
entity.HasKey(cr => new { cr.UserId, cr.CompanyId }); entity.HasKey(cr => new { cr.UserProfileId, cr.CompanyId });
entity.HasOne(cr => cr.User) entity.HasOne(cr => cr.UserProfile)
.WithMany(u => u.CompanyRatings); .WithMany(up => up.CompanyRatings);
entity.HasOne(cr => cr.Company) entity.HasOne(cr => cr.Company)
.WithMany(c => c.CompanyRatings); .WithMany(c => c.CompanyRatings);
@ -88,8 +90,8 @@ public class ApplicationDbContext : DbContext
entity.HasMany(ctv => ctv.CompanyTables) entity.HasMany(ctv => ctv.CompanyTables)
.WithMany(); .WithMany();
entity.HasMany(ctv => ctv.Users) entity.HasMany(ctv => ctv.UserProfiles)
.WithMany(u => u.CompanyTableViews); .WithMany(up => up.CompanyTableViews);
}); });
// Product // Product
@ -122,10 +124,10 @@ public class ApplicationDbContext : DbContext
// Product Rating // Product Rating
modelBuilder.Entity<DbProductRating>(entity => modelBuilder.Entity<DbProductRating>(entity =>
{ {
entity.HasKey(pr => new { pr.UserId, pr.ProductId }); entity.HasKey(pr => new { pr.UserProfileId, pr.ProductId });
entity.HasOne(pr => pr.User) entity.HasOne(pr => pr.UserProfile)
.WithMany(u => u.ProductRatings); .WithMany(up => up.ProductRatings);
entity.HasOne(pr => pr.Product) entity.HasOne(pr => pr.Product)
.WithMany(p => p.ProductRatings); .WithMany(p => p.ProductRatings);
@ -152,62 +154,66 @@ public class ApplicationDbContext : DbContext
entity.HasMany(ptv => ptv.ProductTables) entity.HasMany(ptv => ptv.ProductTables)
.WithMany(); .WithMany();
entity.HasMany(ptv => ptv.Users) entity.HasMany(ptv => ptv.UserProfiles)
.WithMany(u => u.ProductTableViews); .WithMany(u => u.ProductTableViews);
}); });
// User // User
modelBuilder.Entity<DbUser>(entity => modelBuilder.Entity<DbUserProfile>(entity =>
{ {
entity.HasKey(u => u.Id); entity.HasKey(up => up.Id);
entity.HasMany(u => u.CompanyTableViews) entity.HasMany(up => up.CompanyTableViews)
.WithMany(ctv => ctv.Users); .WithMany(ctv => ctv.UserProfiles);
entity.HasMany(u => u.ProductTableViews) entity.HasMany(up => up.ProductTableViews)
.WithMany(ptv => ptv.Users); .WithMany(ptv => ptv.UserProfiles);
entity.HasMany(u => u.CompanyRatings) entity.HasMany(up => up.CompanyRatings)
.WithOne(cr => cr.User) .WithOne(cr => cr.UserProfile)
.HasForeignKey(cr => cr.UserId); .HasForeignKey(cr => cr.UserProfileId);
entity.HasMany(u => u.ProductRatings) entity.HasMany(up => up.ProductRatings)
.WithOne(pr => pr.User) .WithOne(pr => pr.UserProfile)
.HasForeignKey(pr => pr.UserId); .HasForeignKey(pr => pr.UserProfileId);
entity.HasMany(u => u.UserCompanyTableStats) entity.HasMany(up => up.UserProfileCompanyTableStats)
.WithOne(ucts => ucts.User) .WithOne(upcts => upcts.UserProfile)
.HasForeignKey(ucts => ucts.UserId); .HasForeignKey(upcts => upcts.UserId);
entity.HasMany(u => u.UserProductTableStats) entity.HasMany(up => up.UserProfileProductTableStats)
.WithOne(upts => upts.User) .WithOne(uppts => uppts.UserProfile)
.HasForeignKey(upts => upts.UserId); .HasForeignKey(uppts => uppts.UserId);
entity.HasIndex(u => u.UserName) entity.HasIndex(up => up.UserName)
.IsUnique(); .IsUnique();
entity.HasOne(up => up.ApplicationUser)
.WithOne(au => au.UserProfile)
.HasForeignKey<DbUserProfile>(up => up.ApplicationUserId);
}); });
// User Company Table Stat // User Company Table Stat
modelBuilder.Entity<DbUserCompanyTableStat>(entity => modelBuilder.Entity<DbUserProfileCompanyTableStat>(entity =>
{ {
entity.HasKey(ucts => new { ucts.UserId, ucts.CompanyTableId }); entity.HasKey(upcts => new { upcts.UserId, upcts.CompanyTableId });
entity.HasOne(ucts => ucts.User) entity.HasOne(upcts => upcts.UserProfile)
.WithMany(u => u.UserCompanyTableStats); .WithMany(up => up.UserProfileCompanyTableStats);
entity.HasOne(ucts => ucts.CompanyTable) entity.HasOne(upcts => upcts.CompanyTable)
.WithMany(); .WithMany();
}); });
// User Product Table Stat // User Product Table Stat
modelBuilder.Entity<DbUserProductTableStat>(entity => modelBuilder.Entity<DbUserProfileProductTableStat>(entity =>
{ {
entity.HasKey(upts => new { upts.UserId, upts.ProductTableId }); entity.HasKey(uppts => new { uppts.UserId, uppts.ProductTableId });
entity.HasOne(upts => upts.User) entity.HasOne(uppts => uppts.UserProfile)
.WithMany(u => u.UserProductTableStats); .WithMany(up => up.UserProfileProductTableStats);
entity.HasOne(upts => upts.ProductTable) entity.HasOne(uppts => uppts.ProductTable)
.WithMany(); .WithMany();
}); });
} }

View file

@ -1,10 +1,10 @@
using DrinkRateAPI.DbEntities;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace DrinkRateAPI.Contexts; namespace DrinkRateAPI.Contexts;
public class IdentityDbContext : IdentityDbContext<IdentityUser> public class IdentityDbContext : IdentityDbContext<DbApplicationUser>
{ {
public IdentityDbContext(DbContextOptions<IdentityDbContext> options) : public IdentityDbContext(DbContextOptions<IdentityDbContext> options) :
base(options) base(options)

View file

@ -0,0 +1,8 @@
using Microsoft.AspNetCore.Identity;
namespace DrinkRateAPI.DbEntities;
public class DbApplicationUser : IdentityUser
{
public virtual DbUserProfile UserProfile { get; set; }
}

View file

@ -2,8 +2,8 @@ namespace DrinkRateAPI.DbEntities;
public class DbCompanyRating public class DbCompanyRating
{ {
public Guid UserId { get; set; } public Guid UserProfileId { get; set; }
public DbUser User { get; set; } public DbUserProfile UserProfile { get; set; }
public Guid CompanyId { get; set; } public Guid CompanyId { get; set; }
public DbCompany Company { get; set; } public DbCompany Company { get; set; }

View file

@ -6,7 +6,7 @@ public class DbCompanyTableView
public ICollection<DbCompanyTable> CompanyTables { get; set; } public ICollection<DbCompanyTable> CompanyTables { get; set; }
public ICollection<DbUser> Users { get; set; } public ICollection<DbUserProfile> UserProfiles { get; set; }
// to do: permission types // to do: permission types
} }

View file

@ -2,8 +2,8 @@ namespace DrinkRateAPI.DbEntities;
public class DbProductRating public class DbProductRating
{ {
public Guid UserId { get; set; } public Guid UserProfileId { get; set; }
public DbUser User { get; set; } public DbUserProfile UserProfile { get; set; }
public Guid ProductId { get; set; } public Guid ProductId { get; set; }
public DbProduct Product { get; set; } public DbProduct Product { get; set; }

View file

@ -6,7 +6,7 @@ public class DbProductTableView
public ICollection<DbProductTable> ProductTables { get; set; } public ICollection<DbProductTable> ProductTables { get; set; }
public ICollection<DbUser> Users { get; set; } public ICollection<DbUserProfile> UserProfiles { get; set; }
// to do: permission types // to do: permission types
} }

View file

@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Identity;
namespace DrinkRateAPI.DbEntities; namespace DrinkRateAPI.DbEntities;
public class DbUser public class DbUserProfile
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
@ -10,12 +12,16 @@ public class DbUser
public ICollection<DbCompanyRating> CompanyRatings { get; set; } public ICollection<DbCompanyRating> CompanyRatings { get; set; }
public ICollection<DbProductRating> ProductRatings { get; set; } public ICollection<DbProductRating> ProductRatings { get; set; }
public ICollection<DbUserCompanyTableStat> UserCompanyTableStats { get; set; } public ICollection<DbUserProfileCompanyTableStat> UserProfileCompanyTableStats { get; set; }
public ICollection<DbUserProductTableStat> UserProductTableStats { get; set; } public ICollection<DbUserProfileProductTableStat> UserProfileProductTableStats { get; set; }
public string UserName { get; set; } public string UserName { get; set; }
public bool IsAdmin { get; set; } public bool IsAdmin { get; set; }
public bool IsDeleted { get; set; } public bool IsDeleted { get; set; }
public string ApplicationUserId { get; set; }
public virtual DbApplicationUser ApplicationUser { get; set; }
} }

View file

@ -1,9 +1,9 @@
namespace DrinkRateAPI.DbEntities; namespace DrinkRateAPI.DbEntities;
public class DbUserCompanyTableStat public class DbUserProfileCompanyTableStat
{ {
public Guid UserId { get; set; } public Guid UserId { get; set; }
public DbUser User { get; set; } public DbUserProfile UserProfile { get; set; }
public Guid CompanyTableId { get; set; } public Guid CompanyTableId { get; set; }
public DbCompanyTable CompanyTable { get; set; } public DbCompanyTable CompanyTable { get; set; }

View file

@ -1,9 +1,9 @@
namespace DrinkRateAPI.DbEntities; namespace DrinkRateAPI.DbEntities;
public class DbUserProductTableStat public class DbUserProfileProductTableStat
{ {
public Guid UserId { get; set; } public Guid UserId { get; set; }
public DbUser User { get; set; } public DbUserProfile UserProfile { get; set; }
public Guid ProductTableId { get; set; } public Guid ProductTableId { get; set; }
public DbProductTable ProductTable { get; set; } public DbProductTable ProductTable { get; set; }

View file

@ -19,4 +19,8 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project> </Project>

View file

@ -1,29 +0,0 @@
// <auto-generated />
using DrinkRateAPI.Contexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DrinkRateAPI.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20250809085523_250809_ApplicationInit")]
partial class _250809_ApplicationInit
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
#pragma warning restore 612, 618
}
}
}

View file

@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DrinkRateAPI.Migrations
{
/// <inheritdoc />
public partial class _250809_ApplicationInit : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View file

@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DrinkRateAPI.Migrations namespace DrinkRateAPI.Migrations
{ {
[DbContext(typeof(ApplicationDbContext))] [DbContext(typeof(ApplicationDbContext))]
[Migration("20250809121142_BaseDbModel")] [Migration("20250809134029_Init")]
partial class BaseDbModel partial class Init
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -40,19 +40,19 @@ namespace DrinkRateAPI.Migrations
b.ToTable("DbCompanyTableDbCompanyTableView"); b.ToTable("DbCompanyTableDbCompanyTableView");
}); });
modelBuilder.Entity("DbCompanyTableViewDbUser", b => modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{ {
b.Property<Guid>("CompanyTableViewsId") b.Property<Guid>("CompanyTableViewsId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<Guid>("UsersId") b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.HasKey("CompanyTableViewsId", "UsersId"); b.HasKey("CompanyTableViewsId", "UserProfilesId");
b.HasIndex("UsersId"); b.HasIndex("UserProfilesId");
b.ToTable("DbCompanyTableViewDbUser"); b.ToTable("DbCompanyTableViewDbUserProfile");
}); });
modelBuilder.Entity("DbProductTableDbProductTableView", b => modelBuilder.Entity("DbProductTableDbProductTableView", b =>
@ -70,19 +70,71 @@ namespace DrinkRateAPI.Migrations
b.ToTable("DbProductTableDbProductTableView"); b.ToTable("DbProductTableDbProductTableView");
}); });
modelBuilder.Entity("DbProductTableViewDbUser", b => modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{ {
b.Property<Guid>("ProductTableViewsId") b.Property<Guid>("ProductTableViewsId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<Guid>("UsersId") b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.HasKey("ProductTableViewsId", "UsersId"); b.HasKey("ProductTableViewsId", "UserProfilesId");
b.HasIndex("UsersId"); b.HasIndex("UserProfilesId");
b.ToTable("DbProductTableViewDbUser"); b.ToTable("DbProductTableViewDbUserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.HasColumnType("text");
b.Property<string>("Email")
.HasColumnType("text");
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")
.HasColumnType("text");
b.Property<string>("NormalizedUserName")
.HasColumnType("text");
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")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ApplicationUsers");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
@ -117,7 +169,7 @@ namespace DrinkRateAPI.Migrations
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{ {
b.Property<Guid>("UserId") b.Property<Guid>("UserProfileId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<Guid>("CompanyId") b.Property<Guid>("CompanyId")
@ -129,7 +181,7 @@ namespace DrinkRateAPI.Migrations
b.Property<byte>("Rating") b.Property<byte>("Rating")
.HasColumnType("smallint"); .HasColumnType("smallint");
b.HasKey("UserId", "CompanyId"); b.HasKey("UserProfileId", "CompanyId");
b.HasIndex("CompanyId"); b.HasIndex("CompanyId");
@ -202,7 +254,7 @@ namespace DrinkRateAPI.Migrations
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{ {
b.Property<Guid>("UserId") b.Property<Guid>("UserProfileId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<Guid>("ProductId") b.Property<Guid>("ProductId")
@ -214,7 +266,7 @@ namespace DrinkRateAPI.Migrations
b.Property<byte>("Rating") b.Property<byte>("Rating")
.HasColumnType("smallint"); .HasColumnType("smallint");
b.HasKey("UserId", "ProductId"); b.HasKey("UserProfileId", "ProductId");
b.HasIndex("ProductId"); b.HasIndex("ProductId");
@ -250,12 +302,16 @@ namespace DrinkRateAPI.Migrations
b.ToTable("ProductTableView"); b.ToTable("ProductTableView");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUser", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<string>("ApplicationUserId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsAdmin") b.Property<bool>("IsAdmin")
.HasColumnType("boolean"); .HasColumnType("boolean");
@ -268,13 +324,16 @@ namespace DrinkRateAPI.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ApplicationUserId")
.IsUnique();
b.HasIndex("UserName") b.HasIndex("UserName")
.IsUnique(); .IsUnique();
b.ToTable("Users"); b.ToTable("UserProfiles");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserCompanyTableStat", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b =>
{ {
b.Property<Guid>("UserId") b.Property<Guid>("UserId")
.HasColumnType("uuid"); .HasColumnType("uuid");
@ -295,10 +354,10 @@ namespace DrinkRateAPI.Migrations
b.HasIndex("CompanyTableId"); b.HasIndex("CompanyTableId");
b.ToTable("UserCompanyTableStats"); b.ToTable("UserProfileCompanyTableStats");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProductTableStat", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{ {
b.Property<Guid>("UserId") b.Property<Guid>("UserId")
.HasColumnType("uuid"); .HasColumnType("uuid");
@ -319,7 +378,7 @@ namespace DrinkRateAPI.Migrations
b.HasIndex("ProductTableId"); b.HasIndex("ProductTableId");
b.ToTable("UserProductTableStats"); b.ToTable("UserProfileProductTableStats");
}); });
modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b => modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b =>
@ -337,7 +396,7 @@ namespace DrinkRateAPI.Migrations
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("DbCompanyTableViewDbUser", b => modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{ {
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null) b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany() .WithMany()
@ -345,9 +404,9 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", null) b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany() .WithMany()
.HasForeignKey("UsersId") .HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
@ -367,7 +426,7 @@ namespace DrinkRateAPI.Migrations
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("DbProductTableViewDbUser", b => modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{ {
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null) b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany() .WithMany()
@ -375,9 +434,9 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", null) b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany() .WithMany()
.HasForeignKey("UsersId") .HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
@ -401,15 +460,15 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("CompanyRatings") .WithMany("CompanyRatings")
.HasForeignKey("UserId") .HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Company"); b.Navigation("Company");
b.Navigation("User"); b.Navigation("UserProfile");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
@ -439,18 +498,29 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("ProductRatings") .WithMany("ProductRatings")
.HasForeignKey("UserId") .HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Product"); b.Navigation("Product");
b.Navigation("User"); b.Navigation("UserProfile");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserCompanyTableStat", b => 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") b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithMany() .WithMany()
@ -458,18 +528,18 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserCompanyTableStats") .WithMany("UserProfileCompanyTableStats")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("CompanyTable"); b.Navigation("CompanyTable");
b.Navigation("User"); b.Navigation("UserProfile");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProductTableStat", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{ {
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable") b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable")
.WithMany() .WithMany()
@ -477,15 +547,21 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserProductTableStats") .WithMany("UserProfileProductTableStats")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("ProductTable"); b.Navigation("ProductTable");
b.Navigation("User"); b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Navigation("UserProfile")
.IsRequired();
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
@ -510,15 +586,15 @@ namespace DrinkRateAPI.Migrations
b.Navigation("Products"); b.Navigation("Products");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUser", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{ {
b.Navigation("CompanyRatings"); b.Navigation("CompanyRatings");
b.Navigation("ProductRatings"); b.Navigation("ProductRatings");
b.Navigation("UserCompanyTableStats"); b.Navigation("UserProfileCompanyTableStats");
b.Navigation("UserProductTableStats"); b.Navigation("UserProfileProductTableStats");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }

View file

@ -6,11 +6,36 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace DrinkRateAPI.Migrations namespace DrinkRateAPI.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class BaseDbModel : Migration public partial class Init : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.CreateTable(
name: "ApplicationUsers",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
UserName = table.Column<string>(type: "text", nullable: true),
NormalizedUserName = table.Column<string>(type: "text", nullable: true),
Email = table.Column<string>(type: "text", nullable: true),
NormalizedEmail = table.Column<string>(type: "text", nullable: true),
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
PasswordHash = table.Column<string>(type: "text", nullable: true),
SecurityStamp = table.Column<string>(type: "text", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
PhoneNumber = table.Column<string>(type: "text", nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationUsers", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "CompanyTables", name: "CompanyTables",
columns: table => new columns: table => new
@ -58,17 +83,24 @@ namespace DrinkRateAPI.Migrations
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Users", name: "UserProfiles",
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(type: "uuid", nullable: false), Id = table.Column<Guid>(type: "uuid", nullable: false),
UserName = table.Column<string>(type: "text", nullable: false), UserName = table.Column<string>(type: "text", nullable: false),
IsAdmin = table.Column<bool>(type: "boolean", nullable: false), IsAdmin = table.Column<bool>(type: "boolean", nullable: false),
IsDeleted = table.Column<bool>(type: "boolean", nullable: false) IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
ApplicationUserId = table.Column<string>(type: "text", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Users", x => x.Id); table.PrimaryKey("PK_UserProfiles", x => x.Id);
table.ForeignKey(
name: "FK_UserProfiles_ApplicationUsers_ApplicationUserId",
column: x => x.ApplicationUserId,
principalTable: "ApplicationUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
@ -141,55 +173,55 @@ namespace DrinkRateAPI.Migrations
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "DbCompanyTableViewDbUser", name: "DbCompanyTableViewDbUserProfile",
columns: table => new columns: table => new
{ {
CompanyTableViewsId = table.Column<Guid>(type: "uuid", nullable: false), CompanyTableViewsId = table.Column<Guid>(type: "uuid", nullable: false),
UsersId = table.Column<Guid>(type: "uuid", nullable: false) UserProfilesId = table.Column<Guid>(type: "uuid", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_DbCompanyTableViewDbUser", x => new { x.CompanyTableViewsId, x.UsersId }); table.PrimaryKey("PK_DbCompanyTableViewDbUserProfile", x => new { x.CompanyTableViewsId, x.UserProfilesId });
table.ForeignKey( table.ForeignKey(
name: "FK_DbCompanyTableViewDbUser_CompanyTableViews_CompanyTableView~", name: "FK_DbCompanyTableViewDbUserProfile_CompanyTableViews_CompanyTa~",
column: x => x.CompanyTableViewsId, column: x => x.CompanyTableViewsId,
principalTable: "CompanyTableViews", principalTable: "CompanyTableViews",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_DbCompanyTableViewDbUser_Users_UsersId", name: "FK_DbCompanyTableViewDbUserProfile_UserProfiles_UserProfilesId",
column: x => x.UsersId, column: x => x.UserProfilesId,
principalTable: "Users", principalTable: "UserProfiles",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "DbProductTableViewDbUser", name: "DbProductTableViewDbUserProfile",
columns: table => new columns: table => new
{ {
ProductTableViewsId = table.Column<Guid>(type: "uuid", nullable: false), ProductTableViewsId = table.Column<Guid>(type: "uuid", nullable: false),
UsersId = table.Column<Guid>(type: "uuid", nullable: false) UserProfilesId = table.Column<Guid>(type: "uuid", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_DbProductTableViewDbUser", x => new { x.ProductTableViewsId, x.UsersId }); table.PrimaryKey("PK_DbProductTableViewDbUserProfile", x => new { x.ProductTableViewsId, x.UserProfilesId });
table.ForeignKey( table.ForeignKey(
name: "FK_DbProductTableViewDbUser_ProductTableView_ProductTableViews~", name: "FK_DbProductTableViewDbUserProfile_ProductTableView_ProductTab~",
column: x => x.ProductTableViewsId, column: x => x.ProductTableViewsId,
principalTable: "ProductTableView", principalTable: "ProductTableView",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_DbProductTableViewDbUser_Users_UsersId", name: "FK_DbProductTableViewDbUserProfile_UserProfiles_UserProfilesId",
column: x => x.UsersId, column: x => x.UserProfilesId,
principalTable: "Users", principalTable: "UserProfiles",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "UserCompanyTableStats", name: "UserProfileCompanyTableStats",
columns: table => new columns: table => new
{ {
UserId = table.Column<Guid>(type: "uuid", nullable: false), UserId = table.Column<Guid>(type: "uuid", nullable: false),
@ -200,23 +232,23 @@ namespace DrinkRateAPI.Migrations
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_UserCompanyTableStats", x => new { x.UserId, x.CompanyTableId }); table.PrimaryKey("PK_UserProfileCompanyTableStats", x => new { x.UserId, x.CompanyTableId });
table.ForeignKey( table.ForeignKey(
name: "FK_UserCompanyTableStats_CompanyTables_CompanyTableId", name: "FK_UserProfileCompanyTableStats_CompanyTables_CompanyTableId",
column: x => x.CompanyTableId, column: x => x.CompanyTableId,
principalTable: "CompanyTables", principalTable: "CompanyTables",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_UserCompanyTableStats_Users_UserId", name: "FK_UserProfileCompanyTableStats_UserProfiles_UserId",
column: x => x.UserId, column: x => x.UserId,
principalTable: "Users", principalTable: "UserProfiles",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "UserProductTableStats", name: "UserProfileProductTableStats",
columns: table => new columns: table => new
{ {
UserId = table.Column<Guid>(type: "uuid", nullable: false), UserId = table.Column<Guid>(type: "uuid", nullable: false),
@ -227,17 +259,17 @@ namespace DrinkRateAPI.Migrations
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_UserProductTableStats", x => new { x.UserId, x.ProductTableId }); table.PrimaryKey("PK_UserProfileProductTableStats", x => new { x.UserId, x.ProductTableId });
table.ForeignKey( table.ForeignKey(
name: "FK_UserProductTableStats_ProductTable_ProductTableId", name: "FK_UserProfileProductTableStats_ProductTable_ProductTableId",
column: x => x.ProductTableId, column: x => x.ProductTableId,
principalTable: "ProductTable", principalTable: "ProductTable",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_UserProductTableStats_Users_UserId", name: "FK_UserProfileProductTableStats_UserProfiles_UserId",
column: x => x.UserId, column: x => x.UserId,
principalTable: "Users", principalTable: "UserProfiles",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
@ -246,14 +278,14 @@ namespace DrinkRateAPI.Migrations
name: "CompanyRatings", name: "CompanyRatings",
columns: table => new columns: table => new
{ {
UserId = table.Column<Guid>(type: "uuid", nullable: false), UserProfileId = table.Column<Guid>(type: "uuid", nullable: false),
CompanyId = table.Column<Guid>(type: "uuid", nullable: false), CompanyId = table.Column<Guid>(type: "uuid", nullable: false),
Rating = table.Column<byte>(type: "smallint", nullable: false), Rating = table.Column<byte>(type: "smallint", nullable: false),
Comment = table.Column<string>(type: "text", nullable: true) Comment = table.Column<string>(type: "text", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_CompanyRatings", x => new { x.UserId, x.CompanyId }); table.PrimaryKey("PK_CompanyRatings", x => new { x.UserProfileId, x.CompanyId });
table.ForeignKey( table.ForeignKey(
name: "FK_CompanyRatings_Companies_CompanyId", name: "FK_CompanyRatings_Companies_CompanyId",
column: x => x.CompanyId, column: x => x.CompanyId,
@ -261,9 +293,9 @@ namespace DrinkRateAPI.Migrations
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_CompanyRatings_Users_UserId", name: "FK_CompanyRatings_UserProfiles_UserProfileId",
column: x => x.UserId, column: x => x.UserProfileId,
principalTable: "Users", principalTable: "UserProfiles",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
@ -300,14 +332,14 @@ namespace DrinkRateAPI.Migrations
name: "ProductRating", name: "ProductRating",
columns: table => new columns: table => new
{ {
UserId = table.Column<Guid>(type: "uuid", nullable: false), UserProfileId = table.Column<Guid>(type: "uuid", nullable: false),
ProductId = table.Column<Guid>(type: "uuid", nullable: false), ProductId = table.Column<Guid>(type: "uuid", nullable: false),
Rating = table.Column<byte>(type: "smallint", nullable: false), Rating = table.Column<byte>(type: "smallint", nullable: false),
Comment = table.Column<string>(type: "text", nullable: true) Comment = table.Column<string>(type: "text", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_ProductRating", x => new { x.UserId, x.ProductId }); table.PrimaryKey("PK_ProductRating", x => new { x.UserProfileId, x.ProductId });
table.ForeignKey( table.ForeignKey(
name: "FK_ProductRating_Product_ProductId", name: "FK_ProductRating_Product_ProductId",
column: x => x.ProductId, column: x => x.ProductId,
@ -315,9 +347,9 @@ namespace DrinkRateAPI.Migrations
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_ProductRating_Users_UserId", name: "FK_ProductRating_UserProfiles_UserProfileId",
column: x => x.UserId, column: x => x.UserProfileId,
principalTable: "Users", principalTable: "UserProfiles",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
@ -350,9 +382,9 @@ namespace DrinkRateAPI.Migrations
column: "DbCompanyTableViewId"); column: "DbCompanyTableViewId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DbCompanyTableViewDbUser_UsersId", name: "IX_DbCompanyTableViewDbUserProfile_UserProfilesId",
table: "DbCompanyTableViewDbUser", table: "DbCompanyTableViewDbUserProfile",
column: "UsersId"); column: "UserProfilesId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DbProductTableDbProductTableView_ProductTablesId", name: "IX_DbProductTableDbProductTableView_ProductTablesId",
@ -360,9 +392,9 @@ namespace DrinkRateAPI.Migrations
column: "ProductTablesId"); column: "ProductTablesId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DbProductTableViewDbUser_UsersId", name: "IX_DbProductTableViewDbUserProfile_UserProfilesId",
table: "DbProductTableViewDbUser", table: "DbProductTableViewDbUserProfile",
column: "UsersId"); column: "UserProfilesId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Product_CompanyId", name: "IX_Product_CompanyId",
@ -392,18 +424,24 @@ namespace DrinkRateAPI.Migrations
unique: true); unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_UserCompanyTableStats_CompanyTableId", name: "IX_UserProfileCompanyTableStats_CompanyTableId",
table: "UserCompanyTableStats", table: "UserProfileCompanyTableStats",
column: "CompanyTableId"); column: "CompanyTableId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_UserProductTableStats_ProductTableId", name: "IX_UserProfileProductTableStats_ProductTableId",
table: "UserProductTableStats", table: "UserProfileProductTableStats",
column: "ProductTableId"); column: "ProductTableId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Users_UserName", name: "IX_UserProfiles_ApplicationUserId",
table: "Users", table: "UserProfiles",
column: "ApplicationUserId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserProfiles_UserName",
table: "UserProfiles",
column: "UserName", column: "UserName",
unique: true); unique: true);
} }
@ -418,22 +456,22 @@ namespace DrinkRateAPI.Migrations
name: "DbCompanyTableDbCompanyTableView"); name: "DbCompanyTableDbCompanyTableView");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "DbCompanyTableViewDbUser"); name: "DbCompanyTableViewDbUserProfile");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "DbProductTableDbProductTableView"); name: "DbProductTableDbProductTableView");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "DbProductTableViewDbUser"); name: "DbProductTableViewDbUserProfile");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "ProductRating"); name: "ProductRating");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "UserCompanyTableStats"); name: "UserProfileCompanyTableStats");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "UserProductTableStats"); name: "UserProfileProductTableStats");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "CompanyTableViews"); name: "CompanyTableViews");
@ -445,7 +483,7 @@ namespace DrinkRateAPI.Migrations
name: "Product"); name: "Product");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Users"); name: "UserProfiles");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Companies"); name: "Companies");
@ -453,6 +491,9 @@ namespace DrinkRateAPI.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "ProductTable"); name: "ProductTable");
migrationBuilder.DropTable(
name: "ApplicationUsers");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "CompanyTables"); name: "CompanyTables");
} }

View file

@ -37,19 +37,19 @@ namespace DrinkRateAPI.Migrations
b.ToTable("DbCompanyTableDbCompanyTableView"); b.ToTable("DbCompanyTableDbCompanyTableView");
}); });
modelBuilder.Entity("DbCompanyTableViewDbUser", b => modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{ {
b.Property<Guid>("CompanyTableViewsId") b.Property<Guid>("CompanyTableViewsId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<Guid>("UsersId") b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.HasKey("CompanyTableViewsId", "UsersId"); b.HasKey("CompanyTableViewsId", "UserProfilesId");
b.HasIndex("UsersId"); b.HasIndex("UserProfilesId");
b.ToTable("DbCompanyTableViewDbUser"); b.ToTable("DbCompanyTableViewDbUserProfile");
}); });
modelBuilder.Entity("DbProductTableDbProductTableView", b => modelBuilder.Entity("DbProductTableDbProductTableView", b =>
@ -67,19 +67,71 @@ namespace DrinkRateAPI.Migrations
b.ToTable("DbProductTableDbProductTableView"); b.ToTable("DbProductTableDbProductTableView");
}); });
modelBuilder.Entity("DbProductTableViewDbUser", b => modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{ {
b.Property<Guid>("ProductTableViewsId") b.Property<Guid>("ProductTableViewsId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<Guid>("UsersId") b.Property<Guid>("UserProfilesId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.HasKey("ProductTableViewsId", "UsersId"); b.HasKey("ProductTableViewsId", "UserProfilesId");
b.HasIndex("UsersId"); b.HasIndex("UserProfilesId");
b.ToTable("DbProductTableViewDbUser"); b.ToTable("DbProductTableViewDbUserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.HasColumnType("text");
b.Property<string>("Email")
.HasColumnType("text");
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")
.HasColumnType("text");
b.Property<string>("NormalizedUserName")
.HasColumnType("text");
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")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ApplicationUsers");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
@ -114,7 +166,7 @@ namespace DrinkRateAPI.Migrations
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b =>
{ {
b.Property<Guid>("UserId") b.Property<Guid>("UserProfileId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<Guid>("CompanyId") b.Property<Guid>("CompanyId")
@ -126,7 +178,7 @@ namespace DrinkRateAPI.Migrations
b.Property<byte>("Rating") b.Property<byte>("Rating")
.HasColumnType("smallint"); .HasColumnType("smallint");
b.HasKey("UserId", "CompanyId"); b.HasKey("UserProfileId", "CompanyId");
b.HasIndex("CompanyId"); b.HasIndex("CompanyId");
@ -199,7 +251,7 @@ namespace DrinkRateAPI.Migrations
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b =>
{ {
b.Property<Guid>("UserId") b.Property<Guid>("UserProfileId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<Guid>("ProductId") b.Property<Guid>("ProductId")
@ -211,7 +263,7 @@ namespace DrinkRateAPI.Migrations
b.Property<byte>("Rating") b.Property<byte>("Rating")
.HasColumnType("smallint"); .HasColumnType("smallint");
b.HasKey("UserId", "ProductId"); b.HasKey("UserProfileId", "ProductId");
b.HasIndex("ProductId"); b.HasIndex("ProductId");
@ -247,12 +299,16 @@ namespace DrinkRateAPI.Migrations
b.ToTable("ProductTableView"); b.ToTable("ProductTableView");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUser", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<string>("ApplicationUserId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsAdmin") b.Property<bool>("IsAdmin")
.HasColumnType("boolean"); .HasColumnType("boolean");
@ -265,13 +321,16 @@ namespace DrinkRateAPI.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ApplicationUserId")
.IsUnique();
b.HasIndex("UserName") b.HasIndex("UserName")
.IsUnique(); .IsUnique();
b.ToTable("Users"); b.ToTable("UserProfiles");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserCompanyTableStat", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b =>
{ {
b.Property<Guid>("UserId") b.Property<Guid>("UserId")
.HasColumnType("uuid"); .HasColumnType("uuid");
@ -292,10 +351,10 @@ namespace DrinkRateAPI.Migrations
b.HasIndex("CompanyTableId"); b.HasIndex("CompanyTableId");
b.ToTable("UserCompanyTableStats"); b.ToTable("UserProfileCompanyTableStats");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProductTableStat", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{ {
b.Property<Guid>("UserId") b.Property<Guid>("UserId")
.HasColumnType("uuid"); .HasColumnType("uuid");
@ -316,7 +375,7 @@ namespace DrinkRateAPI.Migrations
b.HasIndex("ProductTableId"); b.HasIndex("ProductTableId");
b.ToTable("UserProductTableStats"); b.ToTable("UserProfileProductTableStats");
}); });
modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b => modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b =>
@ -334,7 +393,7 @@ namespace DrinkRateAPI.Migrations
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("DbCompanyTableViewDbUser", b => modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b =>
{ {
b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null) b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null)
.WithMany() .WithMany()
@ -342,9 +401,9 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", null) b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany() .WithMany()
.HasForeignKey("UsersId") .HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
@ -364,7 +423,7 @@ namespace DrinkRateAPI.Migrations
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("DbProductTableViewDbUser", b => modelBuilder.Entity("DbProductTableViewDbUserProfile", b =>
{ {
b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null) b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null)
.WithMany() .WithMany()
@ -372,9 +431,9 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", null) b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null)
.WithMany() .WithMany()
.HasForeignKey("UsersId") .HasForeignKey("UserProfilesId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
@ -398,15 +457,15 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("CompanyRatings") .WithMany("CompanyRatings")
.HasForeignKey("UserId") .HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Company"); b.Navigation("Company");
b.Navigation("User"); b.Navigation("UserProfile");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b =>
@ -436,18 +495,29 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("ProductRatings") .WithMany("ProductRatings")
.HasForeignKey("UserId") .HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Product"); b.Navigation("Product");
b.Navigation("User"); b.Navigation("UserProfile");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserCompanyTableStat", b => 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") b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable")
.WithMany() .WithMany()
@ -455,18 +525,18 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserCompanyTableStats") .WithMany("UserProfileCompanyTableStats")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("CompanyTable"); b.Navigation("CompanyTable");
b.Navigation("User"); b.Navigation("UserProfile");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProductTableStat", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b =>
{ {
b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable") b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable")
.WithMany() .WithMany()
@ -474,15 +544,21 @@ namespace DrinkRateAPI.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile")
.WithMany("UserProductTableStats") .WithMany("UserProfileProductTableStats")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("ProductTable"); b.Navigation("ProductTable");
b.Navigation("User"); b.Navigation("UserProfile");
});
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b =>
{
b.Navigation("UserProfile")
.IsRequired();
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b =>
@ -507,15 +583,15 @@ namespace DrinkRateAPI.Migrations
b.Navigation("Products"); b.Navigation("Products");
}); });
modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUser", b => modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b =>
{ {
b.Navigation("CompanyRatings"); b.Navigation("CompanyRatings");
b.Navigation("ProductRatings"); b.Navigation("ProductRatings");
b.Navigation("UserCompanyTableStats"); b.Navigation("UserProfileCompanyTableStats");
b.Navigation("UserProductTableStats"); b.Navigation("UserProfileProductTableStats");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }