From d4c8a39a54de1e2895f1c85ec5e44dbbd21b8216 Mon Sep 17 00:00:00 2001 From: Michael Tarnorutsky Date: Thu, 9 Apr 2020 06:02:39 -0400 Subject: [PATCH] API implementation to create a member for auth (#86) * Create Member Via API implementation * Add TODO to MemberController Co-Authored-By: Paul Scharnofske <31994781+asynts@users.noreply.github.com> * Improve generic usage in MemberControllerTests Co-Authored-By: Paul Scharnofske <31994781+asynts@users.noreply.github.com> * Remove Generic from Entity Result and Add DI Extensions to WebApp.Testing * Add migrations * Remake inital migration Co-authored-by: Paul Scharnofske <31994781+asynts@users.noreply.github.com> --- src/Application/Members/IMembersRepository.cs | 10 +- src/Application/Members/MembersRepository.cs | 11 + src/Domain/Common/EntityResult.cs | 35 + .../Identity/CurrentUserService.cs | 7 +- .../20200406010139_Initial.Designer.cs | 3488 +++++++++++++++++ .../Migrations/20200406010139_Initial.cs | 2278 +++++++++++ .../ApplicationDbContextModelSnapshot.cs | 3486 ++++++++++++++++ src/WebApp/Controllers/MemberController.cs | 46 + src/WebApp/Models/MemberRequest.cs | 8 + src/WebApp/Startup.cs | 7 +- .../Controllers/MemberControllerTests.cs | 49 + .../WebApp.IntegrationTests.csproj | 1 + 12 files changed, 9421 insertions(+), 5 deletions(-) create mode 100644 src/Domain/Common/EntityResult.cs create mode 100644 src/Infrastructure/Persistence/Migrations/20200406010139_Initial.Designer.cs create mode 100644 src/Infrastructure/Persistence/Migrations/20200406010139_Initial.cs create mode 100644 src/Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs create mode 100644 src/WebApp/Controllers/MemberController.cs create mode 100644 src/WebApp/Models/MemberRequest.cs create mode 100644 tests/WebApp.IntegrationTests/Controllers/MemberControllerTests.cs diff --git a/src/Application/Members/IMembersRepository.cs b/src/Application/Members/IMembersRepository.cs index 714ee96..7b204ac 100644 --- a/src/Application/Members/IMembersRepository.cs +++ b/src/Application/Members/IMembersRepository.cs @@ -1,4 +1,5 @@ -using Codidact.Core.Domain.Entities; +using Codidact.Core.Domain.Common; +using Codidact.Core.Domain.Entities; using System.Threading.Tasks; namespace Codidact.Core.Application.Members @@ -14,5 +15,12 @@ public interface IMembersRepository /// The user id to search for /// Member Task GetSingleByUserIdAsync(long userId); + + /// + /// Creates a new member + /// + /// + /// + Task Create(Member member); } } diff --git a/src/Application/Members/MembersRepository.cs b/src/Application/Members/MembersRepository.cs index a83bc1b..cb6c3b7 100644 --- a/src/Application/Members/MembersRepository.cs +++ b/src/Application/Members/MembersRepository.cs @@ -1,6 +1,8 @@ using Codidact.Core.Application.Common.Interfaces; +using Codidact.Core.Domain.Common; using Codidact.Core.Domain.Entities; using Microsoft.EntityFrameworkCore; +using System.Threading; using System.Threading.Tasks; namespace Codidact.Core.Application.Members @@ -17,5 +19,14 @@ public async Task GetSingleByUserIdAsync(long userId) { return await _context.Members.SingleAsync(member => member.UserId == userId).ConfigureAwait(false); } + + public async Task Create(Member member) + { + _context.Members.Add(member); + + await _context.SaveChangesAsync(CancellationToken.None); + + return new EntityResult(member.Id); + } } } diff --git a/src/Domain/Common/EntityResult.cs b/src/Domain/Common/EntityResult.cs new file mode 100644 index 0000000..387aadf --- /dev/null +++ b/src/Domain/Common/EntityResult.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Codidact.Core.Domain.Common +{ + public class EntityResult + { + public List Errors { get; set; } = new List(); + + public bool Success { get; set; } + + public long? Id { get; set; } + + public EntityResult() + { + + } + + public EntityResult(bool success) + { + Success = success; + } + + public EntityResult(long id) + { + Id = id; + Success = true; + } + + public EntityResult(params string[] error) + { + Errors = error.ToList(); + } + } +} diff --git a/src/Infrastructure/Identity/CurrentUserService.cs b/src/Infrastructure/Identity/CurrentUserService.cs index eca7e30..44ff162 100644 --- a/src/Infrastructure/Identity/CurrentUserService.cs +++ b/src/Infrastructure/Identity/CurrentUserService.cs @@ -35,15 +35,18 @@ public string GetUserId() /// public long GetMemberId() { + var context = _httpContextAccessor.HttpContext; var claimsIdentity = _httpContextAccessor.HttpContext.User.Claims as ClaimsIdentity; Claim memberClaim = _httpContextAccessor.HttpContext?.User.Claims.FirstOrDefault(claim => claim.Type == "codidact_member_id"); - if (!string.IsNullOrEmpty(memberClaim.Value)) + if (!string.IsNullOrEmpty(memberClaim?.Value)) { return long.Parse(memberClaim.Value); } else { - throw new Exception("Claim for memberId is missing in token"); + // TODO: remove this hack. Currently 0, maybe don't set memberId if its not existant.; + return 0; + // throw new Exception("Claim for memberId is missing in token"); } } } diff --git a/src/Infrastructure/Persistence/Migrations/20200406010139_Initial.Designer.cs b/src/Infrastructure/Persistence/Migrations/20200406010139_Initial.Designer.cs new file mode 100644 index 0000000..6724df6 --- /dev/null +++ b/src/Infrastructure/Persistence/Migrations/20200406010139_Initial.Designer.cs @@ -0,0 +1,3488 @@ +// +using System; +using Codidact.Core.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace Codidact.Core.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20200406010139_Initial")] + partial class Initial + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:Enum:audit.history_activity_type", "CREATE,UPDATE_BEFORE,UPDATE_AFTER,DELETE") + .HasAnnotation("Npgsql:PostgresExtension:adminpack", ",,") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .HasAnnotation("ProductVersion", "3.1.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Calculations") + .ValueGeneratedOnAdd() + .HasColumnName("calculations") + .HasColumnType("bigint") + .HasDefaultValueSql("0"); + + b.Property("ContributesToTrustLevel") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("contributes_to_trust_level") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("IsPrimary") + .HasColumnName("is_primary") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("LongExplanation") + .HasColumnName("long_explanation") + .HasColumnType("text"); + + b.Property("ParticipationMinimumTrustLevelId") + .HasColumnName("participation_minimum_trust_level_id") + .HasColumnType("bigint"); + + b.Property("ShortExplanation") + .HasColumnName("short_explanation") + .HasColumnType("text"); + + b.Property("UrlPart") + .HasColumnName("url_part") + .HasColumnType("character varying(20)") + .HasMaxLength(20); + + b.HasKey("Id") + .HasName("pk_categories"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_categories_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_categories_last_modified_by_member_id"); + + b.HasIndex("ParticipationMinimumTrustLevelId") + .HasName("ix_categories_participation_minimum_trust_level_id"); + + b.ToTable("categories"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Calculations") + .ValueGeneratedOnAdd() + .HasColumnName("calculations") + .HasColumnType("bigint") + .HasDefaultValueSql("0"); + + b.Property("ContributesToTrustLevel") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("contributes_to_trust_level") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsPrimary") + .HasColumnName("is_primary") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("LongExplanation") + .HasColumnName("long_explanation") + .HasColumnType("text"); + + b.Property("ShortExplanation") + .HasColumnName("short_explanation") + .HasColumnType("text"); + + b.Property("UrlPart") + .HasColumnName("url_part") + .HasColumnType("character varying(20)") + .HasMaxLength(20); + + b.HasKey("HistoryId") + .HasName("category_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_category_histories_history_activity_member_id"); + + b.ToTable("category_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryPostType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CategoryId") + .HasColumnName("category_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("IsActive") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_active") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostTypeId") + .HasColumnName("post_type_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_category_post_types"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_category_post_types_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_category_post_types_last_modified_by_member_id"); + + b.HasIndex("CategoryId", "PostTypeId") + .IsUnique() + .HasName("category_post_type_category_post_type_uc"); + + b.ToTable("category_post_types"); + + b.HasComment("CategoryPostType"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryPostTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CategoryId") + .HasColumnName("category_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsActive") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_active") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostTypeId") + .HasColumnName("post_type_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("category_post_type_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_category_post_type_histories_history_activity_member_id"); + + b.ToTable("category_post_type_histories","audit"); + + b.HasComment("CategoryPostType"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Comment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("Downvotes") + .HasColumnName("downvotes") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("NetVotes") + .ValueGeneratedOnAddOrUpdate() + .HasColumnName("net_votes") + .HasColumnType("bigint") + .HasComputedColumnSql("(upvotes - downvotes)"); + + b.Property("ParentCommentId") + .HasColumnName("parent_comment_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("Score") + .HasColumnName("score") + .HasColumnType("numeric"); + + b.Property("Upvotes") + .HasColumnName("upvotes") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_comments"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_comments_created_by_member_id"); + + b.HasIndex("DeletedByMemberId") + .HasName("ix_comments_deleted_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_comments_last_modified_by_member_id"); + + b.HasIndex("MemberId") + .HasName("ix_comments_member_id"); + + b.HasIndex("ParentCommentId") + .HasName("ix_comments_parent_comment_id"); + + b.HasIndex("PostId") + .HasName("ix_comments_post_id"); + + b.ToTable("comments"); + + b.HasComment("Table for the comments on posts, both questions and answers."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("Downvotes") + .HasColumnName("downvotes") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("NetVotes") + .ValueGeneratedOnAddOrUpdate() + .HasColumnName("net_votes") + .HasColumnType("bigint") + .HasComputedColumnSql("(upvotes - downvotes)"); + + b.Property("ParentCommentId") + .HasColumnName("parent_comment_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("Score") + .HasColumnName("score") + .HasColumnType("numeric"); + + b.Property("Upvotes") + .HasColumnName("upvotes") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("comment_history_pk"); + + b.HasIndex("DeletedByMemberId") + .HasName("ix_comment_histories_deleted_by_member_id"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_comment_histories_history_activity_member_id"); + + b.ToTable("comment_histories","audit"); + + b.HasComment("Table for the comments on posts, both questions and answers."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentVote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CommentId") + .HasColumnName("comment_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("VoteTypeId") + .HasColumnName("vote_type_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_comment_votes"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_comment_votes_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_comment_votes_last_modified_by_member_id"); + + b.HasIndex("MemberId") + .HasName("ix_comment_votes_member_id"); + + b.HasIndex("VoteTypeId") + .HasName("ix_comment_votes_vote_type_id"); + + b.HasIndex("CommentId", "MemberId") + .IsUnique() + .HasName("comment_vote_comment_member_uc"); + + b.ToTable("comment_votes"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentVoteHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CommentId") + .HasColumnName("comment_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("VoteTypeId") + .HasColumnName("vote_type_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("comment_vote_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_comment_vote_histories_history_activity_member_id"); + + b.ToTable("comment_vote_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Member", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Bio") + .HasColumnName("bio") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("IsAdministrator") + .HasColumnName("is_administrator") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("IsModerator") + .HasColumnName("is_moderator") + .HasColumnType("boolean"); + + b.Property("IsSyncedWithNetworkAccount") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_synced_with_network_account") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("IsTemporarilySuspended") + .HasColumnName("is_temporarily_suspended") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("NetworkAccountId") + .HasColumnName("network_account_id") + .HasColumnType("bigint") + .HasComment("link to 'network_account' table?"); + + b.Property("ProfilePictureLink") + .HasColumnName("profile_picture_link") + .HasColumnType("text"); + + b.Property("TemporarySuspensionEndAt") + .HasColumnName("temporary_suspension_end_at") + .HasColumnType("timestamp without time zone"); + + b.Property("TemporarySuspensionReason") + .HasColumnName("temporary_suspension_reason") + .HasColumnType("text"); + + b.Property("TrustLevelId") + .HasColumnName("trust_level_id") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnName("user_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_members"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_members_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_members_last_modified_by_member_id"); + + b.HasIndex("TrustLevelId") + .HasName("ix_members_trust_level_id"); + + b.ToTable("members"); + + b.HasComment("This table will hold the global member records for a Codidact Instance. A member should only have one email to login with, that would be stored here. Does not include details such as password storage and hashing."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Bio") + .HasColumnName("bio") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsAdministrator") + .HasColumnName("is_administrator") + .HasColumnType("boolean"); + + b.Property("IsModerator") + .HasColumnName("is_moderator") + .HasColumnType("boolean"); + + b.Property("IsSyncedWithNetworkAccount") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_synced_with_network_account") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("IsTemporarilySuspended") + .HasColumnName("is_temporarily_suspended") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("NetworkAccountId") + .HasColumnName("network_account_id") + .HasColumnType("bigint") + .HasComment("link to 'network_account' table?"); + + b.Property("ProfilePictureLink") + .HasColumnName("profile_picture_link") + .HasColumnType("text"); + + b.Property("TemporarySuspensionEndAt") + .HasColumnName("temporary_suspension_end_at") + .HasColumnType("timestamp without time zone"); + + b.Property("TemporarySuspensionReason") + .HasColumnName("temporary_suspension_reason") + .HasColumnType("text"); + + b.Property("TrustLevelId") + .HasColumnName("trust_level_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("member_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_member_histories_history_activity_member_id"); + + b.ToTable("member_histories","audit"); + + b.HasComment("This table will hold the global member records for a Codidact Instance. A member should only have one email to login with, that would be stored here. Does not include details such as password storage and hashing."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberPrivilege", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("IsSuspended") + .HasColumnName("is_suspended") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("PrivilegeId") + .HasColumnName("privilege_id") + .HasColumnType("bigint"); + + b.Property("PrivilegeSuspensionEndAt") + .HasColumnName("privilege_suspension_end_at") + .HasColumnType("timestamp without time zone"); + + b.Property("PrivilegeSuspensionStartAt") + .HasColumnName("privilege_suspension_start_at") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id") + .HasName("pk_member_privileges"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_member_privileges_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_member_privileges_last_modified_by_member_id"); + + b.HasIndex("PrivilegeId") + .HasName("ix_member_privileges_privilege_id"); + + b.HasIndex("MemberId", "PrivilegeId") + .IsUnique() + .HasName("member_privilege_member_privilege_uc"); + + b.ToTable("member_privileges"); + + b.HasComment("For recording which members have which privilege in a community. If a member has a privilege suspended, then that is also recorded here, and a nightly task will auto undo the suspension once the privelege_suspension_end_date has passed."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberPrivilegeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsSuspended") + .HasColumnName("is_suspended") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("PrivilegeId") + .HasColumnName("privilege_id") + .HasColumnType("bigint"); + + b.Property("PrivilegeSuspensionEndAt") + .HasColumnName("privilege_suspension_end_at") + .HasColumnType("timestamp without time zone"); + + b.Property("PrivilegeSuspensionStartAt") + .HasColumnName("privilege_suspension_start_at") + .HasColumnType("timestamp without time zone"); + + b.HasKey("HistoryId") + .HasName("member_privilege_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_member_privilege_history_history_activity_member_id"); + + b.ToTable("member_privilege_history","audit"); + + b.HasComment("For recording which members have which privilege in a community. If a member has a privilege suspended, then that is also recorded here, and a nightly task will auto undo the suspension once the privelege_suspension_end_date has passed."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberSocialMediaType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Content") + .HasColumnName("content") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("SocialMediaId") + .HasColumnName("social_media_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_member_social_media_types"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_member_social_media_types_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_member_social_media_types_last_modified_by_member_id"); + + b.HasIndex("SocialMediaId") + .HasName("ix_member_social_media_types_social_media_id"); + + b.HasIndex("MemberId", "SocialMediaId") + .IsUnique() + .HasName("member_social_media_social_media_member_uc"); + + b.ToTable("member_social_media_types"); + + b.HasComment("The social media that the member would like to display in their community specific profile"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberSocialMediaTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Content") + .HasColumnName("content") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("SocialMediaId") + .HasColumnName("social_media_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("member_social_media_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_member_social_media_type_histories_history_activity_member_~"); + + b.ToTable("member_social_media_type_histories","audit"); + + b.HasComment("The social media that the member would like to display in their community specific profile"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Post", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CategoryId") + .HasColumnName("category_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("Downvotes") + .HasColumnName("downvotes") + .HasColumnType("smallint"); + + b.Property("IsAccepted") + .HasColumnName("is_accepted") + .HasColumnType("boolean"); + + b.Property("IsClosed") + .HasColumnName("is_closed") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("IsProtected") + .HasColumnName("is_protected") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("NetVotes") + .ValueGeneratedOnAddOrUpdate() + .HasColumnName("net_votes") + .HasColumnType("bigint") + .HasComputedColumnSql("(upvotes - downvotes)"); + + b.Property("ParentPostId") + .HasColumnName("parent_post_id") + .HasColumnType("bigint"); + + b.Property("PostTypeId") + .HasColumnName("post_type_id") + .HasColumnType("bigint"); + + b.Property("Score") + .HasColumnName("score") + .HasColumnType("numeric"); + + b.Property("Title") + .IsRequired() + .HasColumnName("title") + .HasColumnType("text"); + + b.Property("Upvotes") + .HasColumnName("upvotes") + .HasColumnType("smallint"); + + b.Property("Views") + .HasColumnName("views") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_posts"); + + b.HasIndex("CategoryId") + .HasName("ix_posts_category_id"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_posts_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_posts_last_modified_by_member_id"); + + b.HasIndex("MemberId") + .HasName("ix_posts_member_id"); + + b.HasIndex("ParentPostId") + .HasName("ix_posts_parent_post_id"); + + b.HasIndex("PostTypeId") + .HasName("ix_posts_post_type_id"); + + b.ToTable("posts"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostDuplicatePost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DuplicatePostId") + .HasColumnName("duplicate_post_id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("OriginalPostId") + .HasColumnName("original_post_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_duplicate_posts"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_duplicate_posts_created_by_member_id"); + + b.HasIndex("DuplicatePostId") + .HasName("ix_post_duplicate_posts_duplicate_post_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_duplicate_posts_last_modified_by_member_id"); + + b.HasIndex("OriginalPostId", "DuplicatePostId") + .IsUnique() + .HasName("post_duplicate_post_original_post_duplicate_post_uc"); + + b.ToTable("post_duplicate_posts"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostDuplicatePostHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DuplicatePostId") + .HasColumnName("duplicate_post_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("OriginalPostId") + .HasColumnName("original_post_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_duplicate_post_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_duplicate_post_histories_history_activity_member_id"); + + b.ToTable("post_duplicate_post_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CategoryId") + .HasColumnName("category_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Downvotes") + .HasColumnName("downvotes") + .HasColumnType("smallint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsAccepted") + .HasColumnName("is_accepted") + .HasColumnType("boolean"); + + b.Property("IsClosed") + .HasColumnName("is_closed") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("IsProtected") + .HasColumnName("is_protected") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("NetVotes") + .ValueGeneratedOnAddOrUpdate() + .HasColumnName("net_votes") + .HasColumnType("bigint") + .HasComputedColumnSql("(upvotes - downvotes)"); + + b.Property("ParentPostId") + .HasColumnName("parent_post_id") + .HasColumnType("bigint"); + + b.Property("PostTypeId") + .HasColumnName("post_type_id") + .HasColumnType("bigint"); + + b.Property("Score") + .HasColumnName("score") + .HasColumnType("numeric"); + + b.Property("Title") + .IsRequired() + .HasColumnName("title") + .HasColumnType("text"); + + b.Property("Upvotes") + .HasColumnName("upvotes") + .HasColumnType("smallint"); + + b.Property("Views") + .HasColumnName("views") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_histories_history_activity_member_id"); + + b.ToTable("post_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("PostStatusTypeId") + .HasColumnName("post_status_type_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_statuss"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_statuss_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_statuss_last_modified_by_member_id"); + + b.HasIndex("PostStatusTypeId") + .HasName("ix_post_statuss_post_status_type_id"); + + b.HasIndex("PostId", "PostStatusTypeId") + .IsUnique() + .HasName("post_status_post_status_type_post_uc"); + + b.ToTable("post_statuss"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("PostStatusTypeId") + .HasColumnName("post_status_type_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_status_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_status_histories_history_activity_member_id"); + + b.ToTable("post_status_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("smallint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_status_types"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_status_types_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("ix_post_status_types_display_name"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_status_types_last_modified_by_member_id"); + + b.ToTable("post_status_types"); + + b.HasComment("For setting the status of a post locked/featured etc"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("smallint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_status_type_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_status_type_histories_history_activity_member_id"); + + b.ToTable("post_status_type_histories","audit"); + + b.HasComment("For setting the status of a post locked/featured etc"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnName("tag_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_tags"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_tags_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_tags_last_modified_by_member_id"); + + b.HasIndex("TagId") + .HasName("ix_post_tags_tag_id"); + + b.HasIndex("PostId", "TagId") + .IsUnique() + .HasName("post_tag_post_tag_uc"); + + b.ToTable("post_tags"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTagHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnName("tag_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_tag_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_tag_histories_history_activity_member_id"); + + b.ToTable("post_tag_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_types"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_types_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("ix_post_types_display_name"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_types_last_modified_by_member_id"); + + b.ToTable("post_types"); + + b.HasComment("Records the type of post, question/answer/blog etc"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_type_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_type_histories_history_activity_member_id"); + + b.ToTable("post_type_histories","audit"); + + b.HasComment("Records the type of post, question/answer/blog etc"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostVote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("VoteTypeId") + .HasColumnName("vote_type_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_votes"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_votes_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_votes_last_modified_by_member_id"); + + b.HasIndex("MemberId") + .HasName("ix_post_votes_member_id"); + + b.HasIndex("VoteTypeId") + .HasName("ix_post_votes_vote_type_id"); + + b.HasIndex("PostId", "MemberId") + .IsUnique() + .HasName("post_vote_post_member_uc"); + + b.ToTable("post_votes"); + + b.HasComment("The reason for this table is so that votes by spammers/serial voters can be undone."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostVoteHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("VoteTypeId") + .HasColumnName("vote_type_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_vote_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_vote_histories_history_activity_member_id"); + + b.ToTable("post_vote_histories","audit"); + + b.HasComment("The reason for this table is so that votes by spammers/serial voters can be undone."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Privilege", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_privileges"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_privileges_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("privilege_display_name_uc"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_privileges_last_modified_by_member_id"); + + b.ToTable("privileges"); + + b.HasComment("Table for privileges"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PrivilegeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("privilege_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_privilege_histories_history_activity_member_id"); + + b.ToTable("privilege_histories","audit"); + + b.HasComment("Table for privileges"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_settings"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_settings_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_settings_last_modified_by_member_id"); + + b.ToTable("settings"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SettingHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("setting_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_setting_histories_history_activity_member_id"); + + b.ToTable("setting_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SocialMediaType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("AccountUrl") + .IsRequired() + .HasColumnName("account_url") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_social_media_types"); + + b.HasIndex("AccountUrl") + .IsUnique() + .HasName("social_media_type_account_url_uc"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_social_media_types_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("social_media_type_display_name_uc"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_social_media_types_last_modified_by_member_id"); + + b.ToTable("social_media_types"); + + b.HasComment("The types of social media that the member can display in their profile"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SocialMediaTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("AccountUrl") + .IsRequired() + .HasColumnName("account_url") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("social_media_type_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_social_media_type_histories_history_activity_member_id"); + + b.ToTable("social_media_type_histories","audit"); + + b.HasComment("The types of social media that the member can display in their profile"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("IsActive") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_active") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("ParentTagId") + .HasColumnName("parent_tag_id") + .HasColumnType("bigint"); + + b.Property("SynonymTagId") + .HasColumnName("synonym_tag_id") + .HasColumnType("bigint"); + + b.Property("TagWiki") + .HasColumnName("tag_wiki") + .HasColumnType("text"); + + b.Property("Usages") + .HasColumnName("usages") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_tags"); + + b.HasIndex("Body") + .IsUnique() + .HasName("tag_body_uc"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_tags_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_tags_last_modified_by_member_id"); + + b.HasIndex("ParentTagId") + .HasName("ix_tags_parent_tag_id"); + + b.ToTable("tags"); + + b.HasComment("Table for all of the tags"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TagHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityMemberId1") + .HasColumnName("history_activity_member_id1") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsActive") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_active") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("ParentTagId") + .HasColumnName("parent_tag_id") + .HasColumnType("bigint"); + + b.Property("SynonymTagId") + .HasColumnName("synonym_tag_id") + .HasColumnType("bigint"); + + b.Property("TagWiki") + .HasColumnName("tag_wiki") + .HasColumnType("text"); + + b.Property("Usages") + .HasColumnName("usages") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("tag_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_tag_histories_history_activity_member_id"); + + b.HasIndex("HistoryActivityMemberId1") + .HasName("ix_tag_histories_history_activity_member_id1"); + + b.ToTable("tag_histories","audit"); + + b.HasComment("Table for all of the tags - history"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TrustLevel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("Explanation") + .IsRequired() + .HasColumnName("explanation") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_trust_levels"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_trust_levels_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("trust_level_display_name_uq"); + + b.HasIndex("Explanation") + .IsUnique() + .HasName("trust_level_explanation_uq"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_trust_levels_last_modified_by_member_id"); + + b.ToTable("trust_levels"); + + b.HasComment("Name for each trust level and an explanation of each that a user should get when they get to that level."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TrustLevelHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("Explanation") + .IsRequired() + .HasColumnName("explanation") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("trust_level_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_trust_level_histories_history_activity_member_id"); + + b.ToTable("trust_level_histories","audit"); + + b.HasComment("Name for each trust level and an explanation of each that a user should get when they get to that level."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.VoteType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_vote_types"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_vote_types_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("vote_type_display_name_uc"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_vote_types_last_modified_by_member_id"); + + b.ToTable("vote_types"); + + b.HasComment("Table for the vote types, upvote/downvote."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.VoteTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("vote_type_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_vote_type_histories_history_activity_member_id"); + + b.ToTable("vote_type_histories","audit"); + + b.HasComment("Table for the vote types, upvote/downvote."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Category", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("CategoryCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("category_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("CategoryLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("category_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.TrustLevel", "ParticipationMinimumTrustLevel") + .WithMany("Category") + .HasForeignKey("ParticipationMinimumTrustLevelId") + .HasConstraintName("category_participation_minimum_trust_level_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("CategoryHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("category_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryPostType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("CategoryPostTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("category_post_type_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("CategoryPostTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("category_post_type_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryPostTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("CategoryPostTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("category_post_type_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Comment", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("CommentCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("comment_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "DeletedByMember") + .WithMany() + .HasForeignKey("DeletedByMemberId") + .HasConstraintName("fk_comments_members_deleted_by_member_id"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("CommentLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("comment_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("CommentMember") + .HasForeignKey("MemberId") + .HasConstraintName("comment_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Comment", "ParentComment") + .WithMany("InverseParentComment") + .HasForeignKey("ParentCommentId") + .HasConstraintName("comment_parent_comment_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "Post") + .WithMany("Comment") + .HasForeignKey("PostId") + .HasConstraintName("comment_post_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "DeletedByMember") + .WithMany() + .HasForeignKey("DeletedByMemberId") + .HasConstraintName("fk_comment_histories_members_deleted_by_member_id"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("CommentHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("comment_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentVote", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Comment", "Comment") + .WithMany("CommentVote") + .HasForeignKey("CommentId") + .HasConstraintName("commentvote_comment_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("CommentVoteCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("comment_vote_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("CommentVoteLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("comment_vote_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("CommentVoteMember") + .HasForeignKey("MemberId") + .HasConstraintName("comment_vote_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.VoteType", "VoteType") + .WithMany("CommentVote") + .HasForeignKey("VoteTypeId") + .HasConstraintName("comment_vote_vote_type_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentVoteHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("CommentVoteHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("comment_vote_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Member", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("InverseCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("member_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("InverseLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("member_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.TrustLevel", "TrustLevel") + .WithMany("Member") + .HasForeignKey("TrustLevelId") + .HasConstraintName("member_trust_level_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("MemberHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("member_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberPrivilege", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("MemberPrivilegeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("member_privilege_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("MemberPrivilegeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("member_privilege_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("MemberPrivilegeMember") + .HasForeignKey("MemberId") + .HasConstraintName("member_privilege_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Privilege", "Privilege") + .WithMany("MemberPrivilege") + .HasForeignKey("PrivilegeId") + .HasConstraintName("member_privilege_privlege_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberPrivilegeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("MemberPrivilegeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("member_privilege_histry_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberSocialMediaType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("MemberSocialMediaTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("member_social_media_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("MemberSocialMediaTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("member_social_media_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("MemberSocialMediaTypeMember") + .HasForeignKey("MemberId") + .HasConstraintName("member_social_media_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.SocialMediaType", "SocialMedia") + .WithMany("MemberSocialMediaType") + .HasForeignKey("SocialMediaId") + .HasConstraintName("member_social_media_social_media_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberSocialMediaTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("MemberSocialMediaTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("member_social_media_type_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Post", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Category", "Category") + .WithMany("Post") + .HasForeignKey("CategoryId") + .HasConstraintName("post_category_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("PostMember") + .HasForeignKey("MemberId") + .HasConstraintName("post_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "ParentPost") + .WithMany("InverseParentPost") + .HasForeignKey("ParentPostId") + .HasConstraintName("post_parent_post_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.PostType", "PostType") + .WithMany("Post") + .HasForeignKey("PostTypeId") + .HasConstraintName("post_post_type_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostDuplicatePost", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostDuplicatePostCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_duplicate_post_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "DuplicatePost") + .WithMany("PostDuplicatePostDuplicatePost") + .HasForeignKey("DuplicatePostId") + .HasConstraintName("post_duplicate_post_duplicate_post_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostDuplicatePostLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_duplicate_post_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "OriginalPost") + .WithMany("PostDuplicatePostOriginalPost") + .HasForeignKey("OriginalPostId") + .HasConstraintName("post_duplicate_post_original_post_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostDuplicatePostHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostDuplicatePostHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_duplicate_post_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatus", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostStatusCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_status_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostStatusLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_status_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "Post") + .WithMany("PostStatus") + .HasForeignKey("PostId") + .HasConstraintName("post_status_post_id_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.PostStatusType", "PostStatusType") + .WithMany("PostStatus") + .HasForeignKey("PostStatusTypeId") + .HasConstraintName("post_status_post_status_type_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostStatusHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_status_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostStatusTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_status_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostStatusTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_status_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostStatusTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_status_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTag", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostTagCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_tag_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostTagLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_tag_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "Post") + .WithMany("PostTag") + .HasForeignKey("PostId") + .HasConstraintName("post_tag_post_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Tag", "Tag") + .WithMany("PostTag") + .HasForeignKey("TagId") + .HasConstraintName("post_tag_tag_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTagHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostTagHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_tag_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_type_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_type_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_type_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostVote", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostVoteCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_vote_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostVoteLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_vote_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("PostVoteMember") + .HasForeignKey("MemberId") + .HasConstraintName("post_vote_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "Post") + .WithMany("PostVote") + .HasForeignKey("PostId") + .HasConstraintName("post_vote_post_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.VoteType", "VoteType") + .WithMany("PostVote") + .HasForeignKey("VoteTypeId") + .HasConstraintName("post_vote_vote_type_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostVoteHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostVoteHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_vote_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Privilege", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PrivilegeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("privilege_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PrivilegeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("privilege_last_modified_by_member"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PrivilegeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PrivilegeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("privilege_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Setting", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("SettingCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("setting_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("SettingLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("setting_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SettingHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("SettingHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("setting_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SocialMediaType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("SocialMediaTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("social_media_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("SocialMediaTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("social_media_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SocialMediaTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("SocialMediaTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("social_media_type_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Tag", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("TagCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("tag_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("TagLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("tag_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Tag", "ParentTag") + .WithMany("InverseParentTag") + .HasForeignKey("ParentTagId") + .HasConstraintName("tag_parent_tag_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TagHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryMember") + .WithMany("TagHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("tag_history_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany() + .HasForeignKey("HistoryActivityMemberId1") + .HasConstraintName("fk_tag_histories_members_history_activity_member_id1"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TrustLevel", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("TrustLevelCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("TrustLevelLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TrustLevelHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("TrustLevelHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("trust_level_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.VoteType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("VoteTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("vote_type_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("VoteTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("vote_type_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.VoteTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("VoteTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("vote_type_history_member_fk") + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Infrastructure/Persistence/Migrations/20200406010139_Initial.cs b/src/Infrastructure/Persistence/Migrations/20200406010139_Initial.cs new file mode 100644 index 0000000..3a3b39f --- /dev/null +++ b/src/Infrastructure/Persistence/Migrations/20200406010139_Initial.cs @@ -0,0 +1,2278 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace Codidact.Core.Infrastructure.Persistence.Migrations +{ + public partial class Initial : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "audit"); + + migrationBuilder.AlterDatabase() + .Annotation("Npgsql:Enum:audit.history_activity_type", "CREATE,UPDATE_BEFORE,UPDATE_AFTER,DELETE") + .Annotation("Npgsql:PostgresExtension:adminpack", ",,"); + + migrationBuilder.CreateTable( + name: "posts", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + member_id = table.Column(nullable: false), + title = table.Column(nullable: false), + body = table.Column(nullable: false), + upvotes = table.Column(nullable: false), + downvotes = table.Column(nullable: false), + net_votes = table.Column(nullable: true, computedColumnSql: "(upvotes - downvotes)"), + score = table.Column(type: "numeric", nullable: false), + views = table.Column(nullable: false), + post_type_id = table.Column(nullable: false), + is_accepted = table.Column(nullable: false), + is_closed = table.Column(nullable: false), + is_protected = table.Column(nullable: false), + parent_post_id = table.Column(nullable: true), + category_id = table.Column(nullable: false), + deleted_at = table.Column(nullable: true), + is_deleted = table.Column(nullable: false), + deleted_by_member_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_posts", x => x.id); + table.ForeignKey( + name: "post_parent_post_fk", + column: x => x.parent_post_id, + principalTable: "posts", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "comment_votes", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + comment_id = table.Column(nullable: false), + member_id = table.Column(nullable: false), + vote_type_id = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_comment_votes", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "categories", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + display_name = table.Column(nullable: false), + url_part = table.Column(maxLength: 20, nullable: true), + is_primary = table.Column(nullable: false), + short_explanation = table.Column(nullable: true), + long_explanation = table.Column(nullable: true), + contributes_to_trust_level = table.Column(nullable: false, defaultValueSql: "true"), + calculations = table.Column(nullable: true, defaultValueSql: "0"), + participation_minimum_trust_level_id = table.Column(nullable: false), + deleted_at = table.Column(nullable: true), + is_deleted = table.Column(nullable: false), + deleted_by_member_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_categories", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "category_post_types", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + category_id = table.Column(nullable: false), + post_type_id = table.Column(nullable: false), + is_active = table.Column(nullable: false, defaultValueSql: "true") + }, + constraints: table => + { + table.PrimaryKey("pk_category_post_types", x => x.id); + }, + comment: "CategoryPostType"); + + migrationBuilder.CreateTable( + name: "comments", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + member_id = table.Column(nullable: false), + post_id = table.Column(nullable: false), + parent_comment_id = table.Column(nullable: true), + body = table.Column(nullable: false), + upvotes = table.Column(nullable: false), + downvotes = table.Column(nullable: false), + net_votes = table.Column(nullable: true, computedColumnSql: "(upvotes - downvotes)"), + score = table.Column(type: "numeric", nullable: false), + deleted_at = table.Column(nullable: true), + is_deleted = table.Column(nullable: false), + deleted_by_member_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_comments", x => x.id); + table.ForeignKey( + name: "comment_parent_comment_fk", + column: x => x.parent_comment_id, + principalTable: "comments", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "comment_post_fk", + column: x => x.post_id, + principalTable: "posts", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "Table for the comments on posts, both questions and answers."); + + migrationBuilder.CreateTable( + name: "member_privileges", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + member_id = table.Column(nullable: false), + privilege_id = table.Column(nullable: false), + is_suspended = table.Column(nullable: false), + privilege_suspension_start_at = table.Column(nullable: true), + privilege_suspension_end_at = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_member_privileges", x => x.id); + }, + comment: "For recording which members have which privilege in a community. If a member has a privilege suspended, then that is also recorded here, and a nightly task will auto undo the suspension once the privelege_suspension_end_date has passed."); + + migrationBuilder.CreateTable( + name: "member_social_media_types", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + social_media_id = table.Column(nullable: false), + member_id = table.Column(nullable: false), + content = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_member_social_media_types", x => x.id); + }, + comment: "The social media that the member would like to display in their community specific profile"); + + migrationBuilder.CreateTable( + name: "post_duplicate_posts", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + original_post_id = table.Column(nullable: false), + duplicate_post_id = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_post_duplicate_posts", x => x.id); + table.ForeignKey( + name: "post_duplicate_post_duplicate_post_fk", + column: x => x.duplicate_post_id, + principalTable: "posts", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "post_duplicate_post_original_post_fk", + column: x => x.original_post_id, + principalTable: "posts", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "post_status_types", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + display_name = table.Column(nullable: false), + description = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_post_status_types", x => x.id); + }, + comment: "For setting the status of a post locked/featured etc"); + + migrationBuilder.CreateTable( + name: "post_statuss", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + post_id = table.Column(nullable: false), + post_status_type_id = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_post_statuss", x => x.id); + table.ForeignKey( + name: "post_status_post_id_fk", + column: x => x.post_id, + principalTable: "posts", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "post_status_post_status_type_fk", + column: x => x.post_status_type_id, + principalTable: "post_status_types", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "post_tags", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + post_id = table.Column(nullable: false), + tag_id = table.Column(nullable: false), + deleted_at = table.Column(nullable: true), + is_deleted = table.Column(nullable: false), + deleted_by_member_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_post_tags", x => x.id); + table.ForeignKey( + name: "post_tag_post_fk", + column: x => x.post_id, + principalTable: "posts", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "post_types", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + display_name = table.Column(nullable: false), + description = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_post_types", x => x.id); + }, + comment: "Records the type of post, question/answer/blog etc"); + + migrationBuilder.CreateTable( + name: "post_votes", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + post_id = table.Column(nullable: false), + vote_type_id = table.Column(nullable: false), + member_id = table.Column(nullable: false), + deleted_at = table.Column(nullable: true), + is_deleted = table.Column(nullable: false), + deleted_by_member_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_post_votes", x => x.id); + table.ForeignKey( + name: "post_vote_post_fk", + column: x => x.post_id, + principalTable: "posts", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "The reason for this table is so that votes by spammers/serial voters can be undone."); + + migrationBuilder.CreateTable( + name: "privileges", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + display_name = table.Column(nullable: false), + description = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_privileges", x => x.id); + }, + comment: "Table for privileges"); + + migrationBuilder.CreateTable( + name: "settings", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_settings", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "social_media_types", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + display_name = table.Column(nullable: false), + account_url = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_social_media_types", x => x.id); + }, + comment: "The types of social media that the member can display in their profile"); + + migrationBuilder.CreateTable( + name: "tags", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + body = table.Column(nullable: false), + description = table.Column(nullable: true), + tag_wiki = table.Column(nullable: true), + is_active = table.Column(nullable: false, defaultValueSql: "true"), + synonym_tag_id = table.Column(nullable: true), + parent_tag_id = table.Column(nullable: true), + usages = table.Column(nullable: false), + deleted_at = table.Column(nullable: true), + is_deleted = table.Column(nullable: false), + deleted_by_member_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_tags", x => x.id); + table.ForeignKey( + name: "tag_parent_tag_fk", + column: x => x.parent_tag_id, + principalTable: "tags", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "Table for all of the tags"); + + migrationBuilder.CreateTable( + name: "trust_levels", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + display_name = table.Column(nullable: false), + explanation = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_trust_levels", x => x.id); + }, + comment: "Name for each trust level and an explanation of each that a user should get when they get to that level."); + + migrationBuilder.CreateTable( + name: "members", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + display_name = table.Column(nullable: false), + bio = table.Column(nullable: true), + profile_picture_link = table.Column(nullable: true), + is_temporarily_suspended = table.Column(nullable: false), + temporary_suspension_end_at = table.Column(nullable: true), + temporary_suspension_reason = table.Column(nullable: true), + trust_level_id = table.Column(nullable: false), + network_account_id = table.Column(nullable: true, comment: "link to 'network_account' table?"), + is_moderator = table.Column(nullable: false), + is_administrator = table.Column(nullable: false), + is_synced_with_network_account = table.Column(nullable: false, defaultValueSql: "true"), + user_id = table.Column(nullable: false), + deleted_at = table.Column(nullable: true), + is_deleted = table.Column(nullable: false), + deleted_by_member_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_members", x => x.id); + table.ForeignKey( + name: "member_created_by_member_fk", + column: x => x.created_by_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "member_last_modified_by_member_fk", + column: x => x.last_modified_by_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "member_trust_level_fk", + column: x => x.trust_level_id, + principalTable: "trust_levels", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "This table will hold the global member records for a Codidact Instance. A member should only have one email to login with, that would be stored here. Does not include details such as password storage and hashing."); + + migrationBuilder.CreateTable( + name: "vote_types", + columns: table => new + { + id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + display_name = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_vote_types", x => x.id); + table.ForeignKey( + name: "vote_type_created_by_member_fk", + column: x => x.created_by_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "vote_type_last_modified_by_member_fk", + column: x => x.last_modified_by_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "Table for the vote types, upvote/downvote."); + + migrationBuilder.CreateTable( + name: "category_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + display_name = table.Column(nullable: false), + url_part = table.Column(maxLength: 20, nullable: true), + is_primary = table.Column(nullable: false), + short_explanation = table.Column(nullable: true), + long_explanation = table.Column(nullable: true), + contributes_to_trust_level = table.Column(nullable: false, defaultValueSql: "true"), + calculations = table.Column(nullable: true, defaultValueSql: "0") + }, + constraints: table => + { + table.PrimaryKey("category_history_pk", x => x.history_id); + table.ForeignKey( + name: "category_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "category_post_type_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + category_id = table.Column(nullable: false), + post_type_id = table.Column(nullable: false), + is_active = table.Column(nullable: false, defaultValueSql: "true") + }, + constraints: table => + { + table.PrimaryKey("category_post_type_history_pk", x => x.history_id); + table.ForeignKey( + name: "category_post_type_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "CategoryPostType"); + + migrationBuilder.CreateTable( + name: "comment_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + member_id = table.Column(nullable: false), + post_id = table.Column(nullable: false), + parent_comment_id = table.Column(nullable: true), + body = table.Column(nullable: false), + upvotes = table.Column(nullable: false), + downvotes = table.Column(nullable: false), + net_votes = table.Column(nullable: true, computedColumnSql: "(upvotes - downvotes)"), + score = table.Column(type: "numeric", nullable: false), + deleted_at = table.Column(nullable: true), + is_deleted = table.Column(nullable: false), + deleted_by_member_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("comment_history_pk", x => x.history_id); + table.ForeignKey( + name: "fk_comment_histories_members_deleted_by_member_id", + column: x => x.deleted_by_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "comment_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "Table for the comments on posts, both questions and answers."); + + migrationBuilder.CreateTable( + name: "comment_vote_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + comment_id = table.Column(nullable: false), + member_id = table.Column(nullable: false), + vote_type_id = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("comment_vote_history_pk", x => x.history_id); + table.ForeignKey( + name: "comment_vote_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "member_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + display_name = table.Column(nullable: false), + bio = table.Column(nullable: true), + profile_picture_link = table.Column(nullable: true), + is_temporarily_suspended = table.Column(nullable: false), + temporary_suspension_end_at = table.Column(nullable: true), + temporary_suspension_reason = table.Column(nullable: true), + trust_level_id = table.Column(nullable: false), + network_account_id = table.Column(nullable: true, comment: "link to 'network_account' table?"), + is_moderator = table.Column(nullable: false), + is_administrator = table.Column(nullable: false), + is_synced_with_network_account = table.Column(nullable: false, defaultValueSql: "true") + }, + constraints: table => + { + table.PrimaryKey("member_history_pk", x => x.history_id); + table.ForeignKey( + name: "member_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "This table will hold the global member records for a Codidact Instance. A member should only have one email to login with, that would be stored here. Does not include details such as password storage and hashing."); + + migrationBuilder.CreateTable( + name: "member_privilege_history", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + member_id = table.Column(nullable: false), + privilege_id = table.Column(nullable: false), + is_suspended = table.Column(nullable: false), + privilege_suspension_start_at = table.Column(nullable: true), + privilege_suspension_end_at = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("member_privilege_history_pk", x => x.history_id); + table.ForeignKey( + name: "member_privilege_histry_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "For recording which members have which privilege in a community. If a member has a privilege suspended, then that is also recorded here, and a nightly task will auto undo the suspension once the privelege_suspension_end_date has passed."); + + migrationBuilder.CreateTable( + name: "member_social_media_type_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + social_media_id = table.Column(nullable: false), + member_id = table.Column(nullable: false), + content = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("member_social_media_history_pk", x => x.history_id); + table.ForeignKey( + name: "member_social_media_type_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "The social media that the member would like to display in their community specific profile"); + + migrationBuilder.CreateTable( + name: "post_duplicate_post_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + original_post_id = table.Column(nullable: false), + duplicate_post_id = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("post_duplicate_post_history_pk", x => x.history_id); + table.ForeignKey( + name: "post_duplicate_post_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "post_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + member_id = table.Column(nullable: false), + title = table.Column(nullable: false), + body = table.Column(nullable: false), + upvotes = table.Column(nullable: false), + downvotes = table.Column(nullable: false), + net_votes = table.Column(nullable: true, computedColumnSql: "(upvotes - downvotes)"), + score = table.Column(type: "numeric", nullable: false), + views = table.Column(nullable: false), + post_type_id = table.Column(nullable: false), + is_accepted = table.Column(nullable: false), + is_closed = table.Column(nullable: false), + is_protected = table.Column(nullable: false), + parent_post_id = table.Column(nullable: true), + category_id = table.Column(nullable: false), + is_deleted = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("post_history_pk", x => x.history_id); + table.ForeignKey( + name: "post_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "post_status_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + post_id = table.Column(nullable: false), + post_status_type_id = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("post_status_history_pk", x => x.history_id); + table.ForeignKey( + name: "post_status_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "post_status_type_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + display_name = table.Column(nullable: false), + description = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("post_status_type_history_pk", x => x.history_id); + table.ForeignKey( + name: "post_status_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "For setting the status of a post locked/featured etc"); + + migrationBuilder.CreateTable( + name: "post_tag_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + post_id = table.Column(nullable: false), + tag_id = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("post_tag_history_pk", x => x.history_id); + table.ForeignKey( + name: "post_tag_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "post_type_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + display_name = table.Column(nullable: false), + description = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("post_type_history_pk", x => x.history_id); + table.ForeignKey( + name: "post_type_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "Records the type of post, question/answer/blog etc"); + + migrationBuilder.CreateTable( + name: "post_vote_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + post_id = table.Column(nullable: false), + vote_type_id = table.Column(nullable: false), + member_id = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("post_vote_history_pk", x => x.history_id); + table.ForeignKey( + name: "post_vote_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "The reason for this table is so that votes by spammers/serial voters can be undone."); + + migrationBuilder.CreateTable( + name: "privilege_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + display_name = table.Column(nullable: false), + description = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("privilege_history_pk", x => x.history_id); + table.ForeignKey( + name: "privilege_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "Table for privileges"); + + migrationBuilder.CreateTable( + name: "setting_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("setting_history_pk", x => x.history_id); + table.ForeignKey( + name: "setting_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "social_media_type_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + display_name = table.Column(nullable: false), + account_url = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("social_media_type_history_pk", x => x.history_id); + table.ForeignKey( + name: "social_media_type_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "The types of social media that the member can display in their profile"); + + migrationBuilder.CreateTable( + name: "tag_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + history_activity_member_id1 = table.Column(nullable: true), + id = table.Column(nullable: false), + body = table.Column(nullable: false), + description = table.Column(nullable: true), + tag_wiki = table.Column(nullable: true), + is_active = table.Column(nullable: false, defaultValueSql: "true"), + synonym_tag_id = table.Column(nullable: true), + parent_tag_id = table.Column(nullable: true), + usages = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("tag_history_pk", x => x.history_id); + table.ForeignKey( + name: "tag_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "fk_tag_histories_members_history_activity_member_id1", + column: x => x.history_activity_member_id1, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "Table for all of the tags - history"); + + migrationBuilder.CreateTable( + name: "trust_level_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + display_name = table.Column(nullable: false), + explanation = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("trust_level_history_pk", x => x.history_id); + table.ForeignKey( + name: "trust_level_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "Name for each trust level and an explanation of each that a user should get when they get to that level."); + + migrationBuilder.CreateTable( + name: "vote_type_histories", + schema: "audit", + columns: table => new + { + history_id = table.Column(nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), + created_at = table.Column(nullable: false, defaultValueSql: "now()"), + last_modified_at = table.Column(nullable: true, defaultValueSql: "now()"), + created_by_member_id = table.Column(nullable: false), + last_modified_by_member_id = table.Column(nullable: true), + history_activity_at = table.Column(nullable: false, defaultValueSql: "now()"), + history_activity_member_id = table.Column(nullable: false), + id = table.Column(nullable: false), + display_name = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("vote_type_history_pk", x => x.history_id); + table.ForeignKey( + name: "vote_type_history_member_fk", + column: x => x.history_activity_member_id, + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }, + comment: "Table for the vote types, upvote/downvote."); + + migrationBuilder.CreateIndex( + name: "ix_categories_created_by_member_id", + table: "categories", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_categories_last_modified_by_member_id", + table: "categories", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_categories_participation_minimum_trust_level_id", + table: "categories", + column: "participation_minimum_trust_level_id"); + + migrationBuilder.CreateIndex( + name: "ix_category_post_types_created_by_member_id", + table: "category_post_types", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_category_post_types_last_modified_by_member_id", + table: "category_post_types", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "category_post_type_category_post_type_uc", + table: "category_post_types", + columns: new[] { "category_id", "post_type_id" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_comment_votes_created_by_member_id", + table: "comment_votes", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_comment_votes_last_modified_by_member_id", + table: "comment_votes", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_comment_votes_member_id", + table: "comment_votes", + column: "member_id"); + + migrationBuilder.CreateIndex( + name: "ix_comment_votes_vote_type_id", + table: "comment_votes", + column: "vote_type_id"); + + migrationBuilder.CreateIndex( + name: "comment_vote_comment_member_uc", + table: "comment_votes", + columns: new[] { "comment_id", "member_id" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_comments_created_by_member_id", + table: "comments", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_comments_deleted_by_member_id", + table: "comments", + column: "deleted_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_comments_last_modified_by_member_id", + table: "comments", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_comments_member_id", + table: "comments", + column: "member_id"); + + migrationBuilder.CreateIndex( + name: "ix_comments_parent_comment_id", + table: "comments", + column: "parent_comment_id"); + + migrationBuilder.CreateIndex( + name: "ix_comments_post_id", + table: "comments", + column: "post_id"); + + migrationBuilder.CreateIndex( + name: "ix_member_privileges_created_by_member_id", + table: "member_privileges", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_member_privileges_last_modified_by_member_id", + table: "member_privileges", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_member_privileges_privilege_id", + table: "member_privileges", + column: "privilege_id"); + + migrationBuilder.CreateIndex( + name: "member_privilege_member_privilege_uc", + table: "member_privileges", + columns: new[] { "member_id", "privilege_id" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_member_social_media_types_created_by_member_id", + table: "member_social_media_types", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_member_social_media_types_last_modified_by_member_id", + table: "member_social_media_types", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_member_social_media_types_social_media_id", + table: "member_social_media_types", + column: "social_media_id"); + + migrationBuilder.CreateIndex( + name: "member_social_media_social_media_member_uc", + table: "member_social_media_types", + columns: new[] { "member_id", "social_media_id" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_members_created_by_member_id", + table: "members", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_members_last_modified_by_member_id", + table: "members", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_members_trust_level_id", + table: "members", + column: "trust_level_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_duplicate_posts_created_by_member_id", + table: "post_duplicate_posts", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_duplicate_posts_duplicate_post_id", + table: "post_duplicate_posts", + column: "duplicate_post_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_duplicate_posts_last_modified_by_member_id", + table: "post_duplicate_posts", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "post_duplicate_post_original_post_duplicate_post_uc", + table: "post_duplicate_posts", + columns: new[] { "original_post_id", "duplicate_post_id" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_post_status_types_created_by_member_id", + table: "post_status_types", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_status_types_display_name", + table: "post_status_types", + column: "display_name", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_post_status_types_last_modified_by_member_id", + table: "post_status_types", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_statuss_created_by_member_id", + table: "post_statuss", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_statuss_last_modified_by_member_id", + table: "post_statuss", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_statuss_post_status_type_id", + table: "post_statuss", + column: "post_status_type_id"); + + migrationBuilder.CreateIndex( + name: "post_status_post_status_type_post_uc", + table: "post_statuss", + columns: new[] { "post_id", "post_status_type_id" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_post_tags_created_by_member_id", + table: "post_tags", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_tags_last_modified_by_member_id", + table: "post_tags", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_tags_tag_id", + table: "post_tags", + column: "tag_id"); + + migrationBuilder.CreateIndex( + name: "post_tag_post_tag_uc", + table: "post_tags", + columns: new[] { "post_id", "tag_id" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_post_types_created_by_member_id", + table: "post_types", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_types_display_name", + table: "post_types", + column: "display_name", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_post_types_last_modified_by_member_id", + table: "post_types", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_votes_created_by_member_id", + table: "post_votes", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_votes_last_modified_by_member_id", + table: "post_votes", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_votes_member_id", + table: "post_votes", + column: "member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_votes_vote_type_id", + table: "post_votes", + column: "vote_type_id"); + + migrationBuilder.CreateIndex( + name: "post_vote_post_member_uc", + table: "post_votes", + columns: new[] { "post_id", "member_id" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_posts_category_id", + table: "posts", + column: "category_id"); + + migrationBuilder.CreateIndex( + name: "ix_posts_created_by_member_id", + table: "posts", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_posts_last_modified_by_member_id", + table: "posts", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_posts_member_id", + table: "posts", + column: "member_id"); + + migrationBuilder.CreateIndex( + name: "ix_posts_parent_post_id", + table: "posts", + column: "parent_post_id"); + + migrationBuilder.CreateIndex( + name: "ix_posts_post_type_id", + table: "posts", + column: "post_type_id"); + + migrationBuilder.CreateIndex( + name: "ix_privileges_created_by_member_id", + table: "privileges", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "privilege_display_name_uc", + table: "privileges", + column: "display_name", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_privileges_last_modified_by_member_id", + table: "privileges", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_settings_created_by_member_id", + table: "settings", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_settings_last_modified_by_member_id", + table: "settings", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "social_media_type_account_url_uc", + table: "social_media_types", + column: "account_url", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_social_media_types_created_by_member_id", + table: "social_media_types", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "social_media_type_display_name_uc", + table: "social_media_types", + column: "display_name", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_social_media_types_last_modified_by_member_id", + table: "social_media_types", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "tag_body_uc", + table: "tags", + column: "body", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_tags_created_by_member_id", + table: "tags", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_tags_last_modified_by_member_id", + table: "tags", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_tags_parent_tag_id", + table: "tags", + column: "parent_tag_id"); + + migrationBuilder.CreateIndex( + name: "ix_trust_levels_created_by_member_id", + table: "trust_levels", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "trust_level_display_name_uq", + table: "trust_levels", + column: "display_name", + unique: true); + + migrationBuilder.CreateIndex( + name: "trust_level_explanation_uq", + table: "trust_levels", + column: "explanation", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_trust_levels_last_modified_by_member_id", + table: "trust_levels", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_vote_types_created_by_member_id", + table: "vote_types", + column: "created_by_member_id"); + + migrationBuilder.CreateIndex( + name: "vote_type_display_name_uc", + table: "vote_types", + column: "display_name", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_vote_types_last_modified_by_member_id", + table: "vote_types", + column: "last_modified_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_category_histories_history_activity_member_id", + schema: "audit", + table: "category_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_category_post_type_histories_history_activity_member_id", + schema: "audit", + table: "category_post_type_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_comment_histories_deleted_by_member_id", + schema: "audit", + table: "comment_histories", + column: "deleted_by_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_comment_histories_history_activity_member_id", + schema: "audit", + table: "comment_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_comment_vote_histories_history_activity_member_id", + schema: "audit", + table: "comment_vote_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_member_histories_history_activity_member_id", + schema: "audit", + table: "member_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_member_privilege_history_history_activity_member_id", + schema: "audit", + table: "member_privilege_history", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_member_social_media_type_histories_history_activity_member_~", + schema: "audit", + table: "member_social_media_type_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_duplicate_post_histories_history_activity_member_id", + schema: "audit", + table: "post_duplicate_post_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_histories_history_activity_member_id", + schema: "audit", + table: "post_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_status_histories_history_activity_member_id", + schema: "audit", + table: "post_status_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_status_type_histories_history_activity_member_id", + schema: "audit", + table: "post_status_type_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_tag_histories_history_activity_member_id", + schema: "audit", + table: "post_tag_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_type_histories_history_activity_member_id", + schema: "audit", + table: "post_type_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_post_vote_histories_history_activity_member_id", + schema: "audit", + table: "post_vote_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_privilege_histories_history_activity_member_id", + schema: "audit", + table: "privilege_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_setting_histories_history_activity_member_id", + schema: "audit", + table: "setting_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_social_media_type_histories_history_activity_member_id", + schema: "audit", + table: "social_media_type_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_tag_histories_history_activity_member_id", + schema: "audit", + table: "tag_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_tag_histories_history_activity_member_id1", + schema: "audit", + table: "tag_histories", + column: "history_activity_member_id1"); + + migrationBuilder.CreateIndex( + name: "ix_trust_level_histories_history_activity_member_id", + schema: "audit", + table: "trust_level_histories", + column: "history_activity_member_id"); + + migrationBuilder.CreateIndex( + name: "ix_vote_type_histories_history_activity_member_id", + schema: "audit", + table: "vote_type_histories", + column: "history_activity_member_id"); + + migrationBuilder.AddForeignKey( + name: "post_created_by_member_fk", + table: "posts", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_last_modified_by_member_fk", + table: "posts", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_member_fk", + table: "posts", + column: "member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_category_fk", + table: "posts", + column: "category_id", + principalTable: "categories", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_post_type_fk", + table: "posts", + column: "post_type_id", + principalTable: "post_types", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "comment_vote_created_by_member_fk", + table: "comment_votes", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "comment_vote_last_modified_by_member_fk", + table: "comment_votes", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "comment_vote_member_fk", + table: "comment_votes", + column: "member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "commentvote_comment_fk", + table: "comment_votes", + column: "comment_id", + principalTable: "comments", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "comment_vote_vote_type_fk", + table: "comment_votes", + column: "vote_type_id", + principalTable: "vote_types", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "category_created_by_member_fk", + table: "categories", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "category_last_modified_by_member_fk", + table: "categories", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "category_participation_minimum_trust_level_fk", + table: "categories", + column: "participation_minimum_trust_level_id", + principalTable: "trust_levels", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "category_post_type_created_by_member_fk", + table: "category_post_types", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "category_post_type_last_modified_by_member_fk", + table: "category_post_types", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "comment_created_by_member_fk", + table: "comments", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "fk_comments_members_deleted_by_member_id", + table: "comments", + column: "deleted_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "comment_last_modified_by_member_fk", + table: "comments", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "comment_member_fk", + table: "comments", + column: "member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "member_privilege_created_by_member_fk", + table: "member_privileges", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "member_privilege_last_modified_by_member_fk", + table: "member_privileges", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "member_privilege_member_fk", + table: "member_privileges", + column: "member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "member_privilege_privlege_fk", + table: "member_privileges", + column: "privilege_id", + principalTable: "privileges", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "member_social_media_created_by_member_fk", + table: "member_social_media_types", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "member_social_media_last_modified_by_member_fk", + table: "member_social_media_types", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "member_social_media_member_fk", + table: "member_social_media_types", + column: "member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "member_social_media_social_media_fk", + table: "member_social_media_types", + column: "social_media_id", + principalTable: "social_media_types", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_duplicate_post_created_by_member_fk", + table: "post_duplicate_posts", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_duplicate_post_last_modified_by_member_fk", + table: "post_duplicate_posts", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_status_created_by_member_fk", + table: "post_status_types", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_status_last_modified_by_member_fk", + table: "post_status_types", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_status_created_by_member_fk", + table: "post_statuss", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_status_last_modified_by_member_fk", + table: "post_statuss", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_tag_created_by_member_fk", + table: "post_tags", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_tag_last_modified_by_member_fk", + table: "post_tags", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_tag_tag_fk", + table: "post_tags", + column: "tag_id", + principalTable: "tags", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_type_created_by_member_fk", + table: "post_types", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_type_last_modified_by_member_fk", + table: "post_types", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_vote_created_by_member_fk", + table: "post_votes", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_vote_last_modified_by_member_fk", + table: "post_votes", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_vote_member_fk", + table: "post_votes", + column: "member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "post_vote_vote_type_fk", + table: "post_votes", + column: "vote_type_id", + principalTable: "vote_types", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "privilege_created_by_member_fk", + table: "privileges", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "privilege_last_modified_by_member", + table: "privileges", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "setting_created_by_member_fk", + table: "settings", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "setting_last_modified_by_member_fk", + table: "settings", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "social_media_created_by_member_fk", + table: "social_media_types", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "social_media_last_modified_by_member_fk", + table: "social_media_types", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "tag_created_by_member_fk", + table: "tags", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "tag_last_modified_by_member_fk", + table: "tags", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "created_by_member_fk", + table: "trust_levels", + column: "created_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "last_modified_by_member_fk", + table: "trust_levels", + column: "last_modified_by_member_id", + principalTable: "members", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "created_by_member_fk", + table: "trust_levels"); + + migrationBuilder.DropForeignKey( + name: "last_modified_by_member_fk", + table: "trust_levels"); + + migrationBuilder.DropTable( + name: "category_post_types"); + + migrationBuilder.DropTable( + name: "comment_votes"); + + migrationBuilder.DropTable( + name: "member_privileges"); + + migrationBuilder.DropTable( + name: "member_social_media_types"); + + migrationBuilder.DropTable( + name: "post_duplicate_posts"); + + migrationBuilder.DropTable( + name: "post_statuss"); + + migrationBuilder.DropTable( + name: "post_tags"); + + migrationBuilder.DropTable( + name: "post_votes"); + + migrationBuilder.DropTable( + name: "settings"); + + migrationBuilder.DropTable( + name: "category_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "category_post_type_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "comment_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "comment_vote_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "member_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "member_privilege_history", + schema: "audit"); + + migrationBuilder.DropTable( + name: "member_social_media_type_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "post_duplicate_post_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "post_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "post_status_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "post_status_type_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "post_tag_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "post_type_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "post_vote_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "privilege_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "setting_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "social_media_type_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "tag_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "trust_level_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "vote_type_histories", + schema: "audit"); + + migrationBuilder.DropTable( + name: "comments"); + + migrationBuilder.DropTable( + name: "privileges"); + + migrationBuilder.DropTable( + name: "social_media_types"); + + migrationBuilder.DropTable( + name: "post_status_types"); + + migrationBuilder.DropTable( + name: "tags"); + + migrationBuilder.DropTable( + name: "vote_types"); + + migrationBuilder.DropTable( + name: "posts"); + + migrationBuilder.DropTable( + name: "categories"); + + migrationBuilder.DropTable( + name: "post_types"); + + migrationBuilder.DropTable( + name: "members"); + + migrationBuilder.DropTable( + name: "trust_levels"); + } + } +} diff --git a/src/Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs new file mode 100644 index 0000000..2abdd1b --- /dev/null +++ b/src/Infrastructure/Persistence/Migrations/ApplicationDbContextModelSnapshot.cs @@ -0,0 +1,3486 @@ +// +using System; +using Codidact.Core.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace Codidact.Core.Infrastructure.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + partial class ApplicationDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:Enum:audit.history_activity_type", "CREATE,UPDATE_BEFORE,UPDATE_AFTER,DELETE") + .HasAnnotation("Npgsql:PostgresExtension:adminpack", ",,") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .HasAnnotation("ProductVersion", "3.1.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Calculations") + .ValueGeneratedOnAdd() + .HasColumnName("calculations") + .HasColumnType("bigint") + .HasDefaultValueSql("0"); + + b.Property("ContributesToTrustLevel") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("contributes_to_trust_level") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("IsPrimary") + .HasColumnName("is_primary") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("LongExplanation") + .HasColumnName("long_explanation") + .HasColumnType("text"); + + b.Property("ParticipationMinimumTrustLevelId") + .HasColumnName("participation_minimum_trust_level_id") + .HasColumnType("bigint"); + + b.Property("ShortExplanation") + .HasColumnName("short_explanation") + .HasColumnType("text"); + + b.Property("UrlPart") + .HasColumnName("url_part") + .HasColumnType("character varying(20)") + .HasMaxLength(20); + + b.HasKey("Id") + .HasName("pk_categories"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_categories_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_categories_last_modified_by_member_id"); + + b.HasIndex("ParticipationMinimumTrustLevelId") + .HasName("ix_categories_participation_minimum_trust_level_id"); + + b.ToTable("categories"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Calculations") + .ValueGeneratedOnAdd() + .HasColumnName("calculations") + .HasColumnType("bigint") + .HasDefaultValueSql("0"); + + b.Property("ContributesToTrustLevel") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("contributes_to_trust_level") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsPrimary") + .HasColumnName("is_primary") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("LongExplanation") + .HasColumnName("long_explanation") + .HasColumnType("text"); + + b.Property("ShortExplanation") + .HasColumnName("short_explanation") + .HasColumnType("text"); + + b.Property("UrlPart") + .HasColumnName("url_part") + .HasColumnType("character varying(20)") + .HasMaxLength(20); + + b.HasKey("HistoryId") + .HasName("category_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_category_histories_history_activity_member_id"); + + b.ToTable("category_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryPostType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CategoryId") + .HasColumnName("category_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("IsActive") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_active") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostTypeId") + .HasColumnName("post_type_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_category_post_types"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_category_post_types_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_category_post_types_last_modified_by_member_id"); + + b.HasIndex("CategoryId", "PostTypeId") + .IsUnique() + .HasName("category_post_type_category_post_type_uc"); + + b.ToTable("category_post_types"); + + b.HasComment("CategoryPostType"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryPostTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CategoryId") + .HasColumnName("category_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsActive") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_active") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostTypeId") + .HasColumnName("post_type_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("category_post_type_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_category_post_type_histories_history_activity_member_id"); + + b.ToTable("category_post_type_histories","audit"); + + b.HasComment("CategoryPostType"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Comment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("Downvotes") + .HasColumnName("downvotes") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("NetVotes") + .ValueGeneratedOnAddOrUpdate() + .HasColumnName("net_votes") + .HasColumnType("bigint") + .HasComputedColumnSql("(upvotes - downvotes)"); + + b.Property("ParentCommentId") + .HasColumnName("parent_comment_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("Score") + .HasColumnName("score") + .HasColumnType("numeric"); + + b.Property("Upvotes") + .HasColumnName("upvotes") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_comments"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_comments_created_by_member_id"); + + b.HasIndex("DeletedByMemberId") + .HasName("ix_comments_deleted_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_comments_last_modified_by_member_id"); + + b.HasIndex("MemberId") + .HasName("ix_comments_member_id"); + + b.HasIndex("ParentCommentId") + .HasName("ix_comments_parent_comment_id"); + + b.HasIndex("PostId") + .HasName("ix_comments_post_id"); + + b.ToTable("comments"); + + b.HasComment("Table for the comments on posts, both questions and answers."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("Downvotes") + .HasColumnName("downvotes") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("NetVotes") + .ValueGeneratedOnAddOrUpdate() + .HasColumnName("net_votes") + .HasColumnType("bigint") + .HasComputedColumnSql("(upvotes - downvotes)"); + + b.Property("ParentCommentId") + .HasColumnName("parent_comment_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("Score") + .HasColumnName("score") + .HasColumnType("numeric"); + + b.Property("Upvotes") + .HasColumnName("upvotes") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("comment_history_pk"); + + b.HasIndex("DeletedByMemberId") + .HasName("ix_comment_histories_deleted_by_member_id"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_comment_histories_history_activity_member_id"); + + b.ToTable("comment_histories","audit"); + + b.HasComment("Table for the comments on posts, both questions and answers."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentVote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CommentId") + .HasColumnName("comment_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("VoteTypeId") + .HasColumnName("vote_type_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_comment_votes"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_comment_votes_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_comment_votes_last_modified_by_member_id"); + + b.HasIndex("MemberId") + .HasName("ix_comment_votes_member_id"); + + b.HasIndex("VoteTypeId") + .HasName("ix_comment_votes_vote_type_id"); + + b.HasIndex("CommentId", "MemberId") + .IsUnique() + .HasName("comment_vote_comment_member_uc"); + + b.ToTable("comment_votes"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentVoteHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CommentId") + .HasColumnName("comment_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("VoteTypeId") + .HasColumnName("vote_type_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("comment_vote_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_comment_vote_histories_history_activity_member_id"); + + b.ToTable("comment_vote_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Member", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Bio") + .HasColumnName("bio") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("IsAdministrator") + .HasColumnName("is_administrator") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("IsModerator") + .HasColumnName("is_moderator") + .HasColumnType("boolean"); + + b.Property("IsSyncedWithNetworkAccount") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_synced_with_network_account") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("IsTemporarilySuspended") + .HasColumnName("is_temporarily_suspended") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("NetworkAccountId") + .HasColumnName("network_account_id") + .HasColumnType("bigint") + .HasComment("link to 'network_account' table?"); + + b.Property("ProfilePictureLink") + .HasColumnName("profile_picture_link") + .HasColumnType("text"); + + b.Property("TemporarySuspensionEndAt") + .HasColumnName("temporary_suspension_end_at") + .HasColumnType("timestamp without time zone"); + + b.Property("TemporarySuspensionReason") + .HasColumnName("temporary_suspension_reason") + .HasColumnType("text"); + + b.Property("TrustLevelId") + .HasColumnName("trust_level_id") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnName("user_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_members"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_members_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_members_last_modified_by_member_id"); + + b.HasIndex("TrustLevelId") + .HasName("ix_members_trust_level_id"); + + b.ToTable("members"); + + b.HasComment("This table will hold the global member records for a Codidact Instance. A member should only have one email to login with, that would be stored here. Does not include details such as password storage and hashing."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Bio") + .HasColumnName("bio") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsAdministrator") + .HasColumnName("is_administrator") + .HasColumnType("boolean"); + + b.Property("IsModerator") + .HasColumnName("is_moderator") + .HasColumnType("boolean"); + + b.Property("IsSyncedWithNetworkAccount") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_synced_with_network_account") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("IsTemporarilySuspended") + .HasColumnName("is_temporarily_suspended") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("NetworkAccountId") + .HasColumnName("network_account_id") + .HasColumnType("bigint") + .HasComment("link to 'network_account' table?"); + + b.Property("ProfilePictureLink") + .HasColumnName("profile_picture_link") + .HasColumnType("text"); + + b.Property("TemporarySuspensionEndAt") + .HasColumnName("temporary_suspension_end_at") + .HasColumnType("timestamp without time zone"); + + b.Property("TemporarySuspensionReason") + .HasColumnName("temporary_suspension_reason") + .HasColumnType("text"); + + b.Property("TrustLevelId") + .HasColumnName("trust_level_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("member_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_member_histories_history_activity_member_id"); + + b.ToTable("member_histories","audit"); + + b.HasComment("This table will hold the global member records for a Codidact Instance. A member should only have one email to login with, that would be stored here. Does not include details such as password storage and hashing."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberPrivilege", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("IsSuspended") + .HasColumnName("is_suspended") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("PrivilegeId") + .HasColumnName("privilege_id") + .HasColumnType("bigint"); + + b.Property("PrivilegeSuspensionEndAt") + .HasColumnName("privilege_suspension_end_at") + .HasColumnType("timestamp without time zone"); + + b.Property("PrivilegeSuspensionStartAt") + .HasColumnName("privilege_suspension_start_at") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id") + .HasName("pk_member_privileges"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_member_privileges_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_member_privileges_last_modified_by_member_id"); + + b.HasIndex("PrivilegeId") + .HasName("ix_member_privileges_privilege_id"); + + b.HasIndex("MemberId", "PrivilegeId") + .IsUnique() + .HasName("member_privilege_member_privilege_uc"); + + b.ToTable("member_privileges"); + + b.HasComment("For recording which members have which privilege in a community. If a member has a privilege suspended, then that is also recorded here, and a nightly task will auto undo the suspension once the privelege_suspension_end_date has passed."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberPrivilegeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsSuspended") + .HasColumnName("is_suspended") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("PrivilegeId") + .HasColumnName("privilege_id") + .HasColumnType("bigint"); + + b.Property("PrivilegeSuspensionEndAt") + .HasColumnName("privilege_suspension_end_at") + .HasColumnType("timestamp without time zone"); + + b.Property("PrivilegeSuspensionStartAt") + .HasColumnName("privilege_suspension_start_at") + .HasColumnType("timestamp without time zone"); + + b.HasKey("HistoryId") + .HasName("member_privilege_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_member_privilege_history_history_activity_member_id"); + + b.ToTable("member_privilege_history","audit"); + + b.HasComment("For recording which members have which privilege in a community. If a member has a privilege suspended, then that is also recorded here, and a nightly task will auto undo the suspension once the privelege_suspension_end_date has passed."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberSocialMediaType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Content") + .HasColumnName("content") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("SocialMediaId") + .HasColumnName("social_media_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_member_social_media_types"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_member_social_media_types_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_member_social_media_types_last_modified_by_member_id"); + + b.HasIndex("SocialMediaId") + .HasName("ix_member_social_media_types_social_media_id"); + + b.HasIndex("MemberId", "SocialMediaId") + .IsUnique() + .HasName("member_social_media_social_media_member_uc"); + + b.ToTable("member_social_media_types"); + + b.HasComment("The social media that the member would like to display in their community specific profile"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberSocialMediaTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Content") + .HasColumnName("content") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("SocialMediaId") + .HasColumnName("social_media_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("member_social_media_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_member_social_media_type_histories_history_activity_member_~"); + + b.ToTable("member_social_media_type_histories","audit"); + + b.HasComment("The social media that the member would like to display in their community specific profile"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Post", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CategoryId") + .HasColumnName("category_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("Downvotes") + .HasColumnName("downvotes") + .HasColumnType("smallint"); + + b.Property("IsAccepted") + .HasColumnName("is_accepted") + .HasColumnType("boolean"); + + b.Property("IsClosed") + .HasColumnName("is_closed") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("IsProtected") + .HasColumnName("is_protected") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("NetVotes") + .ValueGeneratedOnAddOrUpdate() + .HasColumnName("net_votes") + .HasColumnType("bigint") + .HasComputedColumnSql("(upvotes - downvotes)"); + + b.Property("ParentPostId") + .HasColumnName("parent_post_id") + .HasColumnType("bigint"); + + b.Property("PostTypeId") + .HasColumnName("post_type_id") + .HasColumnType("bigint"); + + b.Property("Score") + .HasColumnName("score") + .HasColumnType("numeric"); + + b.Property("Title") + .IsRequired() + .HasColumnName("title") + .HasColumnType("text"); + + b.Property("Upvotes") + .HasColumnName("upvotes") + .HasColumnType("smallint"); + + b.Property("Views") + .HasColumnName("views") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_posts"); + + b.HasIndex("CategoryId") + .HasName("ix_posts_category_id"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_posts_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_posts_last_modified_by_member_id"); + + b.HasIndex("MemberId") + .HasName("ix_posts_member_id"); + + b.HasIndex("ParentPostId") + .HasName("ix_posts_parent_post_id"); + + b.HasIndex("PostTypeId") + .HasName("ix_posts_post_type_id"); + + b.ToTable("posts"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostDuplicatePost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DuplicatePostId") + .HasColumnName("duplicate_post_id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("OriginalPostId") + .HasColumnName("original_post_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_duplicate_posts"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_duplicate_posts_created_by_member_id"); + + b.HasIndex("DuplicatePostId") + .HasName("ix_post_duplicate_posts_duplicate_post_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_duplicate_posts_last_modified_by_member_id"); + + b.HasIndex("OriginalPostId", "DuplicatePostId") + .IsUnique() + .HasName("post_duplicate_post_original_post_duplicate_post_uc"); + + b.ToTable("post_duplicate_posts"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostDuplicatePostHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DuplicatePostId") + .HasColumnName("duplicate_post_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("OriginalPostId") + .HasColumnName("original_post_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_duplicate_post_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_duplicate_post_histories_history_activity_member_id"); + + b.ToTable("post_duplicate_post_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CategoryId") + .HasColumnName("category_id") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Downvotes") + .HasColumnName("downvotes") + .HasColumnType("smallint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsAccepted") + .HasColumnName("is_accepted") + .HasColumnType("boolean"); + + b.Property("IsClosed") + .HasColumnName("is_closed") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("IsProtected") + .HasColumnName("is_protected") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("NetVotes") + .ValueGeneratedOnAddOrUpdate() + .HasColumnName("net_votes") + .HasColumnType("bigint") + .HasComputedColumnSql("(upvotes - downvotes)"); + + b.Property("ParentPostId") + .HasColumnName("parent_post_id") + .HasColumnType("bigint"); + + b.Property("PostTypeId") + .HasColumnName("post_type_id") + .HasColumnType("bigint"); + + b.Property("Score") + .HasColumnName("score") + .HasColumnType("numeric"); + + b.Property("Title") + .IsRequired() + .HasColumnName("title") + .HasColumnType("text"); + + b.Property("Upvotes") + .HasColumnName("upvotes") + .HasColumnType("smallint"); + + b.Property("Views") + .HasColumnName("views") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_histories_history_activity_member_id"); + + b.ToTable("post_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("PostStatusTypeId") + .HasColumnName("post_status_type_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_statuss"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_statuss_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_statuss_last_modified_by_member_id"); + + b.HasIndex("PostStatusTypeId") + .HasName("ix_post_statuss_post_status_type_id"); + + b.HasIndex("PostId", "PostStatusTypeId") + .IsUnique() + .HasName("post_status_post_status_type_post_uc"); + + b.ToTable("post_statuss"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("PostStatusTypeId") + .HasColumnName("post_status_type_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_status_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_status_histories_history_activity_member_id"); + + b.ToTable("post_status_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("smallint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_status_types"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_status_types_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("ix_post_status_types_display_name"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_status_types_last_modified_by_member_id"); + + b.ToTable("post_status_types"); + + b.HasComment("For setting the status of a post locked/featured etc"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("smallint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_status_type_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_status_type_histories_history_activity_member_id"); + + b.ToTable("post_status_type_histories","audit"); + + b.HasComment("For setting the status of a post locked/featured etc"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnName("tag_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_tags"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_tags_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_tags_last_modified_by_member_id"); + + b.HasIndex("TagId") + .HasName("ix_post_tags_tag_id"); + + b.HasIndex("PostId", "TagId") + .IsUnique() + .HasName("post_tag_post_tag_uc"); + + b.ToTable("post_tags"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTagHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("TagId") + .HasColumnName("tag_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_tag_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_tag_histories_history_activity_member_id"); + + b.ToTable("post_tag_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_types"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_types_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("ix_post_types_display_name"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_types_last_modified_by_member_id"); + + b.ToTable("post_types"); + + b.HasComment("Records the type of post, question/answer/blog etc"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_type_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_type_histories_history_activity_member_id"); + + b.ToTable("post_type_histories","audit"); + + b.HasComment("Records the type of post, question/answer/blog etc"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostVote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("VoteTypeId") + .HasColumnName("vote_type_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_post_votes"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_post_votes_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_post_votes_last_modified_by_member_id"); + + b.HasIndex("MemberId") + .HasName("ix_post_votes_member_id"); + + b.HasIndex("VoteTypeId") + .HasName("ix_post_votes_vote_type_id"); + + b.HasIndex("PostId", "MemberId") + .IsUnique() + .HasName("post_vote_post_member_uc"); + + b.ToTable("post_votes"); + + b.HasComment("The reason for this table is so that votes by spammers/serial voters can be undone."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostVoteHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("MemberId") + .HasColumnName("member_id") + .HasColumnType("bigint"); + + b.Property("PostId") + .HasColumnName("post_id") + .HasColumnType("bigint"); + + b.Property("VoteTypeId") + .HasColumnName("vote_type_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("post_vote_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_post_vote_histories_history_activity_member_id"); + + b.ToTable("post_vote_histories","audit"); + + b.HasComment("The reason for this table is so that votes by spammers/serial voters can be undone."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Privilege", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_privileges"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_privileges_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("privilege_display_name_uc"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_privileges_last_modified_by_member_id"); + + b.ToTable("privileges"); + + b.HasComment("Table for privileges"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PrivilegeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("privilege_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_privilege_histories_history_activity_member_id"); + + b.ToTable("privilege_histories","audit"); + + b.HasComment("Table for privileges"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_settings"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_settings_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_settings_last_modified_by_member_id"); + + b.ToTable("settings"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SettingHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("setting_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_setting_histories_history_activity_member_id"); + + b.ToTable("setting_histories","audit"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SocialMediaType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("AccountUrl") + .IsRequired() + .HasColumnName("account_url") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_social_media_types"); + + b.HasIndex("AccountUrl") + .IsUnique() + .HasName("social_media_type_account_url_uc"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_social_media_types_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("social_media_type_display_name_uc"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_social_media_types_last_modified_by_member_id"); + + b.ToTable("social_media_types"); + + b.HasComment("The types of social media that the member can display in their profile"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SocialMediaTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("AccountUrl") + .IsRequired() + .HasColumnName("account_url") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("social_media_type_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_social_media_type_histories_history_activity_member_id"); + + b.ToTable("social_media_type_histories","audit"); + + b.HasComment("The types of social media that the member can display in their profile"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DeletedAt") + .HasColumnName("deleted_at") + .HasColumnType("timestamp without time zone"); + + b.Property("DeletedByMemberId") + .HasColumnName("deleted_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("IsActive") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_active") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("IsDeleted") + .HasColumnName("is_deleted") + .HasColumnType("boolean"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("ParentTagId") + .HasColumnName("parent_tag_id") + .HasColumnType("bigint"); + + b.Property("SynonymTagId") + .HasColumnName("synonym_tag_id") + .HasColumnType("bigint"); + + b.Property("TagWiki") + .HasColumnName("tag_wiki") + .HasColumnType("text"); + + b.Property("Usages") + .HasColumnName("usages") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_tags"); + + b.HasIndex("Body") + .IsUnique() + .HasName("tag_body_uc"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_tags_created_by_member_id"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_tags_last_modified_by_member_id"); + + b.HasIndex("ParentTagId") + .HasName("ix_tags_parent_tag_id"); + + b.ToTable("tags"); + + b.HasComment("Table for all of the tags"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TagHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("Body") + .IsRequired() + .HasColumnName("body") + .HasColumnType("text"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnName("description") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("HistoryActivityMemberId1") + .HasColumnName("history_activity_member_id1") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("IsActive") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnName("is_active") + .HasColumnType("boolean") + .HasDefaultValueSql("true"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.Property("ParentTagId") + .HasColumnName("parent_tag_id") + .HasColumnType("bigint"); + + b.Property("SynonymTagId") + .HasColumnName("synonym_tag_id") + .HasColumnType("bigint"); + + b.Property("TagWiki") + .HasColumnName("tag_wiki") + .HasColumnType("text"); + + b.Property("Usages") + .HasColumnName("usages") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("tag_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_tag_histories_history_activity_member_id"); + + b.HasIndex("HistoryActivityMemberId1") + .HasName("ix_tag_histories_history_activity_member_id1"); + + b.ToTable("tag_histories","audit"); + + b.HasComment("Table for all of the tags - history"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TrustLevel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("Explanation") + .IsRequired() + .HasColumnName("explanation") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_trust_levels"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_trust_levels_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("trust_level_display_name_uq"); + + b.HasIndex("Explanation") + .IsUnique() + .HasName("trust_level_explanation_uq"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_trust_levels_last_modified_by_member_id"); + + b.ToTable("trust_levels"); + + b.HasComment("Name for each trust level and an explanation of each that a user should get when they get to that level."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TrustLevelHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("Explanation") + .IsRequired() + .HasColumnName("explanation") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("trust_level_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_trust_level_histories_history_activity_member_id"); + + b.ToTable("trust_level_histories","audit"); + + b.HasComment("Name for each trust level and an explanation of each that a user should get when they get to that level."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.VoteType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnName("id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("Id") + .HasName("pk_vote_types"); + + b.HasIndex("CreatedByMemberId") + .HasName("ix_vote_types_created_by_member_id"); + + b.HasIndex("DisplayName") + .IsUnique() + .HasName("vote_type_display_name_uc"); + + b.HasIndex("LastModifiedByMemberId") + .HasName("ix_vote_types_last_modified_by_member_id"); + + b.ToTable("vote_types"); + + b.HasComment("Table for the vote types, upvote/downvote."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.VoteTypeHistory", b => + { + b.Property("HistoryId") + .ValueGeneratedOnAdd() + .HasColumnName("history_id") + .HasColumnType("bigint") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnName("created_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("CreatedByMemberId") + .HasColumnName("created_by_member_id") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("display_name") + .HasColumnType("text"); + + b.Property("HistoryActivityAt") + .ValueGeneratedOnAdd() + .HasColumnName("history_activity_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("HistoryActivityMemberId") + .HasColumnName("history_activity_member_id") + .HasColumnType("bigint"); + + b.Property("Id") + .HasColumnName("id") + .HasColumnType("bigint"); + + b.Property("LastModifiedAt") + .ValueGeneratedOnAdd() + .HasColumnName("last_modified_at") + .HasColumnType("timestamp without time zone") + .HasDefaultValueSql("now()"); + + b.Property("LastModifiedByMemberId") + .HasColumnName("last_modified_by_member_id") + .HasColumnType("bigint"); + + b.HasKey("HistoryId") + .HasName("vote_type_history_pk"); + + b.HasIndex("HistoryActivityMemberId") + .HasName("ix_vote_type_histories_history_activity_member_id"); + + b.ToTable("vote_type_histories","audit"); + + b.HasComment("Table for the vote types, upvote/downvote."); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Category", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("CategoryCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("category_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("CategoryLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("category_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.TrustLevel", "ParticipationMinimumTrustLevel") + .WithMany("Category") + .HasForeignKey("ParticipationMinimumTrustLevelId") + .HasConstraintName("category_participation_minimum_trust_level_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("CategoryHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("category_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryPostType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("CategoryPostTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("category_post_type_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("CategoryPostTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("category_post_type_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CategoryPostTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("CategoryPostTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("category_post_type_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Comment", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("CommentCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("comment_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "DeletedByMember") + .WithMany() + .HasForeignKey("DeletedByMemberId") + .HasConstraintName("fk_comments_members_deleted_by_member_id"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("CommentLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("comment_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("CommentMember") + .HasForeignKey("MemberId") + .HasConstraintName("comment_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Comment", "ParentComment") + .WithMany("InverseParentComment") + .HasForeignKey("ParentCommentId") + .HasConstraintName("comment_parent_comment_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "Post") + .WithMany("Comment") + .HasForeignKey("PostId") + .HasConstraintName("comment_post_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "DeletedByMember") + .WithMany() + .HasForeignKey("DeletedByMemberId") + .HasConstraintName("fk_comment_histories_members_deleted_by_member_id"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("CommentHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("comment_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentVote", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Comment", "Comment") + .WithMany("CommentVote") + .HasForeignKey("CommentId") + .HasConstraintName("commentvote_comment_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("CommentVoteCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("comment_vote_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("CommentVoteLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("comment_vote_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("CommentVoteMember") + .HasForeignKey("MemberId") + .HasConstraintName("comment_vote_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.VoteType", "VoteType") + .WithMany("CommentVote") + .HasForeignKey("VoteTypeId") + .HasConstraintName("comment_vote_vote_type_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.CommentVoteHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("CommentVoteHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("comment_vote_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Member", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("InverseCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("member_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("InverseLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("member_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.TrustLevel", "TrustLevel") + .WithMany("Member") + .HasForeignKey("TrustLevelId") + .HasConstraintName("member_trust_level_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("MemberHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("member_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberPrivilege", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("MemberPrivilegeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("member_privilege_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("MemberPrivilegeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("member_privilege_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("MemberPrivilegeMember") + .HasForeignKey("MemberId") + .HasConstraintName("member_privilege_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Privilege", "Privilege") + .WithMany("MemberPrivilege") + .HasForeignKey("PrivilegeId") + .HasConstraintName("member_privilege_privlege_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberPrivilegeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("MemberPrivilegeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("member_privilege_histry_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberSocialMediaType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("MemberSocialMediaTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("member_social_media_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("MemberSocialMediaTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("member_social_media_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("MemberSocialMediaTypeMember") + .HasForeignKey("MemberId") + .HasConstraintName("member_social_media_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.SocialMediaType", "SocialMedia") + .WithMany("MemberSocialMediaType") + .HasForeignKey("SocialMediaId") + .HasConstraintName("member_social_media_social_media_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.MemberSocialMediaTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("MemberSocialMediaTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("member_social_media_type_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Post", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Category", "Category") + .WithMany("Post") + .HasForeignKey("CategoryId") + .HasConstraintName("post_category_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("PostMember") + .HasForeignKey("MemberId") + .HasConstraintName("post_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "ParentPost") + .WithMany("InverseParentPost") + .HasForeignKey("ParentPostId") + .HasConstraintName("post_parent_post_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.PostType", "PostType") + .WithMany("Post") + .HasForeignKey("PostTypeId") + .HasConstraintName("post_post_type_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostDuplicatePost", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostDuplicatePostCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_duplicate_post_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "DuplicatePost") + .WithMany("PostDuplicatePostDuplicatePost") + .HasForeignKey("DuplicatePostId") + .HasConstraintName("post_duplicate_post_duplicate_post_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostDuplicatePostLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_duplicate_post_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "OriginalPost") + .WithMany("PostDuplicatePostOriginalPost") + .HasForeignKey("OriginalPostId") + .HasConstraintName("post_duplicate_post_original_post_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostDuplicatePostHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostDuplicatePostHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_duplicate_post_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatus", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostStatusCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_status_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostStatusLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_status_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "Post") + .WithMany("PostStatus") + .HasForeignKey("PostId") + .HasConstraintName("post_status_post_id_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.PostStatusType", "PostStatusType") + .WithMany("PostStatus") + .HasForeignKey("PostStatusTypeId") + .HasConstraintName("post_status_post_status_type_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostStatusHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_status_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostStatusTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_status_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostStatusTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_status_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostStatusTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostStatusTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_status_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTag", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostTagCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_tag_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostTagLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_tag_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "Post") + .WithMany("PostTag") + .HasForeignKey("PostId") + .HasConstraintName("post_tag_post_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Tag", "Tag") + .WithMany("PostTag") + .HasForeignKey("TagId") + .HasConstraintName("post_tag_tag_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTagHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostTagHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_tag_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_type_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_type_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_type_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostVote", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PostVoteCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("post_vote_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PostVoteLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("post_vote_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "Member") + .WithMany("PostVoteMember") + .HasForeignKey("MemberId") + .HasConstraintName("post_vote_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Post", "Post") + .WithMany("PostVote") + .HasForeignKey("PostId") + .HasConstraintName("post_vote_post_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.VoteType", "VoteType") + .WithMany("PostVote") + .HasForeignKey("VoteTypeId") + .HasConstraintName("post_vote_vote_type_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PostVoteHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PostVoteHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("post_vote_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Privilege", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("PrivilegeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("privilege_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("PrivilegeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("privilege_last_modified_by_member"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.PrivilegeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("PrivilegeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("privilege_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Setting", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("SettingCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("setting_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("SettingLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("setting_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SettingHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("SettingHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("setting_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SocialMediaType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("SocialMediaTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("social_media_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("SocialMediaTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("social_media_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.SocialMediaTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("SocialMediaTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("social_media_type_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.Tag", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("TagCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("tag_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("TagLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("tag_last_modified_by_member_fk"); + + b.HasOne("Codidact.Core.Domain.Entities.Tag", "ParentTag") + .WithMany("InverseParentTag") + .HasForeignKey("ParentTagId") + .HasConstraintName("tag_parent_tag_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TagHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryMember") + .WithMany("TagHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("tag_history_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany() + .HasForeignKey("HistoryActivityMemberId1") + .HasConstraintName("fk_tag_histories_members_history_activity_member_id1"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TrustLevel", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("TrustLevelCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("TrustLevelLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.TrustLevelHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("TrustLevelHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("trust_level_history_member_fk") + .IsRequired(); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.VoteType", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "CreatedByMember") + .WithMany("VoteTypeCreatedByMember") + .HasForeignKey("CreatedByMemberId") + .HasConstraintName("vote_type_created_by_member_fk") + .IsRequired(); + + b.HasOne("Codidact.Core.Domain.Entities.Member", "LastModifiedByMember") + .WithMany("VoteTypeLastModifiedByMember") + .HasForeignKey("LastModifiedByMemberId") + .HasConstraintName("vote_type_last_modified_by_member_fk"); + }); + + modelBuilder.Entity("Codidact.Core.Domain.Entities.VoteTypeHistory", b => + { + b.HasOne("Codidact.Core.Domain.Entities.Member", "HistoryActivityMember") + .WithMany("VoteTypeHistory") + .HasForeignKey("HistoryActivityMemberId") + .HasConstraintName("vote_type_history_member_fk") + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/WebApp/Controllers/MemberController.cs b/src/WebApp/Controllers/MemberController.cs new file mode 100644 index 0000000..c40cb8c --- /dev/null +++ b/src/WebApp/Controllers/MemberController.cs @@ -0,0 +1,46 @@ +using System; +using System.Threading.Tasks; +using Codidact.Core.Application.Members; +using Codidact.Core.Domain.Common; +using Codidact.Core.Domain.Entities; +using Codidact.Core.WebApp.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace Codidact.Core.WebApp.Controllers +{ + [ApiController] + [Route("api/v1/[controller]")] + public class MemberController : ControllerBase + { + private readonly ILogger _logger; + private readonly IMembersRepository _memberRepository; + + public MemberController( + ILogger logger, + IMembersRepository membersRepository) + { + _logger = logger; + _memberRepository = membersRepository; + } + + [HttpPost("create")] + public async Task Create([FromBody]MemberRequest request) + { + // Todo. Authenticate the request. + + _logger.LogDebug(@$"{DateTime.Now.ToString()}: + Received Request for Create User: + {nameof(request.DisplayName)} {request.DisplayName} + {nameof(request.UserId)} {request.UserId}"); + var result = await _memberRepository.Create( + new Member + { + DisplayName = request.DisplayName, + UserId = request.UserId, + }); + + return result; + } + } +} diff --git a/src/WebApp/Models/MemberRequest.cs b/src/WebApp/Models/MemberRequest.cs new file mode 100644 index 0000000..9550ee4 --- /dev/null +++ b/src/WebApp/Models/MemberRequest.cs @@ -0,0 +1,8 @@ +namespace Codidact.Core.WebApp.Models +{ + public class MemberRequest + { + public string DisplayName { get; set; } + public long UserId { get; set; } + } +} diff --git a/src/WebApp/Startup.cs b/src/WebApp/Startup.cs index a85e4bf..f41c63b 100644 --- a/src/WebApp/Startup.cs +++ b/src/WebApp/Startup.cs @@ -11,7 +11,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; using System.IdentityModel.Tokens.Jwt; namespace Codidact.Core.WebApp @@ -96,7 +95,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger< app.UseAuthentication(); app.UseAuthorization(); - app.UseEndpoints(endpoints => endpoints.MapRazorPages()); + app.UseEndpoints(endpoints => + { + endpoints.MapRazorPages(); + endpoints.MapControllers(); + }); if (env.EnvironmentName != "Test") { diff --git a/tests/WebApp.IntegrationTests/Controllers/MemberControllerTests.cs b/tests/WebApp.IntegrationTests/Controllers/MemberControllerTests.cs new file mode 100644 index 0000000..0c8c592 --- /dev/null +++ b/tests/WebApp.IntegrationTests/Controllers/MemberControllerTests.cs @@ -0,0 +1,49 @@ +using System.Linq; +using System.Threading.Tasks; +using Codidact.Core.Application.Common.Interfaces; +using Codidact.Core.Domain.Common; +using Codidact.Core.WebApp.Models; +using Xunit; +using Microsoft.Extensions.DependencyInjection; + +namespace Codidact.Core.WebApp.IntegrationTests.Controllers +{ + public class MemberControllerTests : + IClassFixture> + { + private readonly CustomWebApplicationFactory _factory; + + public MemberControllerTests( + CustomWebApplicationFactory factory) + { + _factory = factory; + } + + [Fact] + public async Task CreateMember() + { + var client = _factory.CreateClient(); + + var content = IntegrationTestHelper.GetRequestContent( + new MemberRequest + { + DisplayName = "John", + UserId = 1, + }); + + var response = await client.PostAsync($"api/v1/member/create", content); + + response.EnsureSuccessStatusCode(); + + var result = await IntegrationTestHelper.GetResponseContent(response); + + Assert.True(result.Success); + + var context = _factory.Services.GetService(); + + var createdMember = context.Members.FirstOrDefault(member => member.Id == result.Id); + + Assert.NotNull(createdMember); + } + } +} diff --git a/tests/WebApp.IntegrationTests/WebApp.IntegrationTests.csproj b/tests/WebApp.IntegrationTests/WebApp.IntegrationTests.csproj index 67efbbd..eda2228 100644 --- a/tests/WebApp.IntegrationTests/WebApp.IntegrationTests.csproj +++ b/tests/WebApp.IntegrationTests/WebApp.IntegrationTests.csproj @@ -10,6 +10,7 @@ +