aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data
diff options
context:
space:
mode:
Diffstat (limited to 'src/DevHive.Data')
-rw-r--r--src/DevHive.Data/Interfaces/Models/IComment.cs2
-rw-r--r--src/DevHive.Data/Migrations/20210121083441_UserRefactor.cs411
-rw-r--r--src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.Designer.cs (renamed from src/DevHive.Data/Migrations/20210121083441_UserRefactor.Designer.cs)14
-rw-r--r--src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.cs411
-rw-r--r--src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs10
-rw-r--r--src/DevHive.Data/Models/Comment.cs2
-rw-r--r--src/DevHive.Data/Models/Language.cs4
-rw-r--r--src/DevHive.Data/Models/Post.cs4
-rw-r--r--src/DevHive.Data/Models/Role.cs2
-rw-r--r--src/DevHive.Data/Models/Technology.cs4
-rw-r--r--src/DevHive.Data/Models/User.cs8
-rw-r--r--src/DevHive.Data/Repositories/CommentRepository.cs2
-rw-r--r--src/DevHive.Data/Repositories/PostRepository.cs7
13 files changed, 448 insertions, 433 deletions
diff --git a/src/DevHive.Data/Interfaces/Models/IComment.cs b/src/DevHive.Data/Interfaces/Models/IComment.cs
index 6368e3b..9a72da4 100644
--- a/src/DevHive.Data/Interfaces/Models/IComment.cs
+++ b/src/DevHive.Data/Interfaces/Models/IComment.cs
@@ -6,7 +6,7 @@ namespace DevHive.Data.Interfaces.Models
{
Guid PostId { get; set; }
- Guid IssuerId { get; set; }
+ Guid CreatorId { get; set; }
string Message { get; set; }
diff --git a/src/DevHive.Data/Migrations/20210121083441_UserRefactor.cs b/src/DevHive.Data/Migrations/20210121083441_UserRefactor.cs
deleted file mode 100644
index 6eb1e38..0000000
--- a/src/DevHive.Data/Migrations/20210121083441_UserRefactor.cs
+++ /dev/null
@@ -1,411 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-namespace DevHive.Data.Migrations
-{
- public partial class UserRefactor : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "AspNetRoles",
- columns: table => new
- {
- Id = table.Column<Guid>(type: "uuid", nullable: false),
- Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
- NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
- ConcurrencyStamp = table.Column<string>(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_AspNetRoles", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "AspNetUsers",
- columns: table => new
- {
- Id = table.Column<Guid>(type: "uuid", nullable: false),
- FirstName = table.Column<string>(type: "text", nullable: true),
- LastName = table.Column<string>(type: "text", nullable: true),
- ProfilePictureUrl = table.Column<string>(type: "text", nullable: true),
- UserId = table.Column<Guid>(type: "uuid", nullable: true),
- UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
- NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
- Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
- NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
- EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
- PasswordHash = table.Column<string>(type: "text", nullable: true),
- SecurityStamp = table.Column<string>(type: "text", nullable: true),
- ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
- PhoneNumber = table.Column<string>(type: "text", nullable: true),
- PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
- TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
- LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
- LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
- AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_AspNetUsers", x => x.Id);
- table.ForeignKey(
- name: "FK_AspNetUsers_AspNetUsers_UserId",
- column: x => x.UserId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- });
-
- migrationBuilder.CreateTable(
- name: "Languages",
- columns: table => new
- {
- Id = table.Column<Guid>(type: "uuid", nullable: false),
- Name = table.Column<string>(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Languages", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Posts",
- columns: table => new
- {
- Id = table.Column<Guid>(type: "uuid", nullable: false),
- IssuerId = table.Column<Guid>(type: "uuid", nullable: false),
- TimeCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
- Message = table.Column<string>(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Posts", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Technologies",
- columns: table => new
- {
- Id = table.Column<Guid>(type: "uuid", nullable: false),
- Name = table.Column<string>(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Technologies", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "AspNetRoleClaims",
- columns: table => new
- {
- Id = table.Column<int>(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- RoleId = table.Column<Guid>(type: "uuid", nullable: false),
- ClaimType = table.Column<string>(type: "text", nullable: true),
- ClaimValue = table.Column<string>(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
- table.ForeignKey(
- name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
- column: x => x.RoleId,
- principalTable: "AspNetRoles",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "AspNetUserClaims",
- columns: table => new
- {
- Id = table.Column<int>(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- UserId = table.Column<Guid>(type: "uuid", nullable: false),
- ClaimType = table.Column<string>(type: "text", nullable: true),
- ClaimValue = table.Column<string>(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
- table.ForeignKey(
- name: "FK_AspNetUserClaims_AspNetUsers_UserId",
- column: x => x.UserId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "AspNetUserLogins",
- columns: table => new
- {
- LoginProvider = table.Column<string>(type: "text", nullable: false),
- ProviderKey = table.Column<string>(type: "text", nullable: false),
- ProviderDisplayName = table.Column<string>(type: "text", nullable: true),
- UserId = table.Column<Guid>(type: "uuid", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
- table.ForeignKey(
- name: "FK_AspNetUserLogins_AspNetUsers_UserId",
- column: x => x.UserId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "AspNetUserRoles",
- columns: table => new
- {
- UserId = table.Column<Guid>(type: "uuid", nullable: false),
- RoleId = table.Column<Guid>(type: "uuid", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
- table.ForeignKey(
- name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
- column: x => x.RoleId,
- principalTable: "AspNetRoles",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_AspNetUserRoles_AspNetUsers_UserId",
- column: x => x.UserId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "AspNetUserTokens",
- columns: table => new
- {
- UserId = table.Column<Guid>(type: "uuid", nullable: false),
- LoginProvider = table.Column<string>(type: "text", nullable: false),
- Name = table.Column<string>(type: "text", nullable: false),
- Value = table.Column<string>(type: "text", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
- table.ForeignKey(
- name: "FK_AspNetUserTokens_AspNetUsers_UserId",
- column: x => x.UserId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "RoleUser",
- columns: table => new
- {
- RolesId = table.Column<Guid>(type: "uuid", nullable: false),
- UsersId = table.Column<Guid>(type: "uuid", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_RoleUser", x => new { x.RolesId, x.UsersId });
- table.ForeignKey(
- name: "FK_RoleUser_AspNetRoles_RolesId",
- column: x => x.RolesId,
- principalTable: "AspNetRoles",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_RoleUser_AspNetUsers_UsersId",
- column: x => x.UsersId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "LanguageUser",
- columns: table => new
- {
- LanguagesId = table.Column<Guid>(type: "uuid", nullable: false),
- UsersId = table.Column<Guid>(type: "uuid", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_LanguageUser", x => new { x.LanguagesId, x.UsersId });
- table.ForeignKey(
- name: "FK_LanguageUser_AspNetUsers_UsersId",
- column: x => x.UsersId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_LanguageUser_Languages_LanguagesId",
- column: x => x.LanguagesId,
- principalTable: "Languages",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "Comments",
- columns: table => new
- {
- Id = table.Column<Guid>(type: "uuid", nullable: false),
- IssuerId = table.Column<Guid>(type: "uuid", nullable: false),
- Message = table.Column<string>(type: "text", nullable: true),
- TimeCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
- PostId = table.Column<Guid>(type: "uuid", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Comments", x => x.Id);
- table.ForeignKey(
- name: "FK_Comments_Posts_PostId",
- column: x => x.PostId,
- principalTable: "Posts",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- });
-
- migrationBuilder.CreateTable(
- name: "TechnologyUser",
- columns: table => new
- {
- TechnologiesId = table.Column<Guid>(type: "uuid", nullable: false),
- UsersId = table.Column<Guid>(type: "uuid", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_TechnologyUser", x => new { x.TechnologiesId, x.UsersId });
- table.ForeignKey(
- name: "FK_TechnologyUser_AspNetUsers_UsersId",
- column: x => x.UsersId,
- principalTable: "AspNetUsers",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_TechnologyUser_Technologies_TechnologiesId",
- column: x => x.TechnologiesId,
- principalTable: "Technologies",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_AspNetRoleClaims_RoleId",
- table: "AspNetRoleClaims",
- column: "RoleId");
-
- migrationBuilder.CreateIndex(
- name: "RoleNameIndex",
- table: "AspNetRoles",
- column: "NormalizedName",
- unique: true);
-
- migrationBuilder.CreateIndex(
- name: "IX_AspNetUserClaims_UserId",
- table: "AspNetUserClaims",
- column: "UserId");
-
- migrationBuilder.CreateIndex(
- name: "IX_AspNetUserLogins_UserId",
- table: "AspNetUserLogins",
- column: "UserId");
-
- migrationBuilder.CreateIndex(
- name: "IX_AspNetUserRoles_RoleId",
- table: "AspNetUserRoles",
- column: "RoleId");
-
- migrationBuilder.CreateIndex(
- name: "EmailIndex",
- table: "AspNetUsers",
- column: "NormalizedEmail");
-
- migrationBuilder.CreateIndex(
- name: "IX_AspNetUsers_UserId",
- table: "AspNetUsers",
- column: "UserId");
-
- migrationBuilder.CreateIndex(
- name: "IX_AspNetUsers_UserName",
- table: "AspNetUsers",
- column: "UserName",
- unique: true);
-
- migrationBuilder.CreateIndex(
- name: "UserNameIndex",
- table: "AspNetUsers",
- column: "NormalizedUserName",
- unique: true);
-
- migrationBuilder.CreateIndex(
- name: "IX_Comments_PostId",
- table: "Comments",
- column: "PostId");
-
- migrationBuilder.CreateIndex(
- name: "IX_LanguageUser_UsersId",
- table: "LanguageUser",
- column: "UsersId");
-
- migrationBuilder.CreateIndex(
- name: "IX_RoleUser_UsersId",
- table: "RoleUser",
- column: "UsersId");
-
- migrationBuilder.CreateIndex(
- name: "IX_TechnologyUser_UsersId",
- table: "TechnologyUser",
- column: "UsersId");
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "AspNetRoleClaims");
-
- migrationBuilder.DropTable(
- name: "AspNetUserClaims");
-
- migrationBuilder.DropTable(
- name: "AspNetUserLogins");
-
- migrationBuilder.DropTable(
- name: "AspNetUserRoles");
-
- migrationBuilder.DropTable(
- name: "AspNetUserTokens");
-
- migrationBuilder.DropTable(
- name: "Comments");
-
- migrationBuilder.DropTable(
- name: "LanguageUser");
-
- migrationBuilder.DropTable(
- name: "RoleUser");
-
- migrationBuilder.DropTable(
- name: "TechnologyUser");
-
- migrationBuilder.DropTable(
- name: "Posts");
-
- migrationBuilder.DropTable(
- name: "Languages");
-
- migrationBuilder.DropTable(
- name: "AspNetRoles");
-
- migrationBuilder.DropTable(
- name: "AspNetUsers");
-
- migrationBuilder.DropTable(
- name: "Technologies");
- }
- }
-}
diff --git a/src/DevHive.Data/Migrations/20210121083441_UserRefactor.Designer.cs b/src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.Designer.cs
index 7c7a092..0e4b103 100644
--- a/src/DevHive.Data/Migrations/20210121083441_UserRefactor.Designer.cs
+++ b/src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.Designer.cs
@@ -10,8 +10,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DevHive.Data.Migrations
{
[DbContext(typeof(DevHiveContext))]
- [Migration("20210121083441_UserRefactor")]
- partial class UserRefactor
+ [Migration("20210123215634_PostAndComment_Implemented")]
+ partial class PostAndComment_Implemented
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@@ -27,13 +27,13 @@ namespace DevHive.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
- b.Property<Guid>("IssuerId")
+ b.Property<Guid>("CreatorId")
.HasColumnType("uuid");
b.Property<string>("Message")
.HasColumnType("text");
- b.Property<Guid?>("PostId")
+ b.Property<Guid>("PostId")
.HasColumnType("uuid");
b.Property<DateTime>("TimeCreated")
@@ -66,7 +66,7 @@ namespace DevHive.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
- b.Property<Guid>("IssuerId")
+ b.Property<Guid>("CreatorId")
.HasColumnType("uuid");
b.Property<string>("Message")
@@ -353,7 +353,9 @@ namespace DevHive.Data.Migrations
{
b.HasOne("DevHive.Data.Models.Post", null)
.WithMany("Comments")
- .HasForeignKey("PostId");
+ .HasForeignKey("PostId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
});
modelBuilder.Entity("DevHive.Data.Models.User", b =>
diff --git a/src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.cs b/src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.cs
new file mode 100644
index 0000000..4c9f3bd
--- /dev/null
+++ b/src/DevHive.Data/Migrations/20210123215634_PostAndComment_Implemented.cs
@@ -0,0 +1,411 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+namespace DevHive.Data.Migrations
+{
+ public partial class PostAndComment_Implemented : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "AspNetRoles",
+ columns: table => new
+ {
+ Id = table.Column<Guid>(type: "uuid", nullable: false),
+ Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ ConcurrencyStamp = table.Column<string>(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetRoles", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetUsers",
+ columns: table => new
+ {
+ Id = table.Column<Guid>(type: "uuid", nullable: false),
+ FirstName = table.Column<string>(type: "text", nullable: true),
+ LastName = table.Column<string>(type: "text", nullable: true),
+ ProfilePictureUrl = table.Column<string>(type: "text", nullable: true),
+ UserId = table.Column<Guid>(type: "uuid", nullable: true),
+ UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
+ EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
+ PasswordHash = table.Column<string>(type: "text", nullable: true),
+ SecurityStamp = table.Column<string>(type: "text", nullable: true),
+ ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
+ PhoneNumber = table.Column<string>(type: "text", nullable: true),
+ PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
+ TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
+ LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
+ LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
+ AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetUsers", x => x.Id);
+ table.ForeignKey(
+ name: "FK_AspNetUsers_AspNetUsers_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Languages",
+ columns: table => new
+ {
+ Id = table.Column<Guid>(type: "uuid", nullable: false),
+ Name = table.Column<string>(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Languages", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Posts",
+ columns: table => new
+ {
+ Id = table.Column<Guid>(type: "uuid", nullable: false),
+ CreatorId = table.Column<Guid>(type: "uuid", nullable: false),
+ Message = table.Column<string>(type: "text", nullable: true),
+ TimeCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Posts", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Technologies",
+ columns: table => new
+ {
+ Id = table.Column<Guid>(type: "uuid", nullable: false),
+ Name = table.Column<string>(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Technologies", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetRoleClaims",
+ columns: table => new
+ {
+ Id = table.Column<int>(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ RoleId = table.Column<Guid>(type: "uuid", nullable: false),
+ ClaimType = table.Column<string>(type: "text", nullable: true),
+ ClaimValue = table.Column<string>(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
+ table.ForeignKey(
+ name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
+ column: x => x.RoleId,
+ principalTable: "AspNetRoles",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetUserClaims",
+ columns: table => new
+ {
+ Id = table.Column<int>(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ UserId = table.Column<Guid>(type: "uuid", nullable: false),
+ ClaimType = table.Column<string>(type: "text", nullable: true),
+ ClaimValue = table.Column<string>(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
+ table.ForeignKey(
+ name: "FK_AspNetUserClaims_AspNetUsers_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetUserLogins",
+ columns: table => new
+ {
+ LoginProvider = table.Column<string>(type: "text", nullable: false),
+ ProviderKey = table.Column<string>(type: "text", nullable: false),
+ ProviderDisplayName = table.Column<string>(type: "text", nullable: true),
+ UserId = table.Column<Guid>(type: "uuid", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
+ table.ForeignKey(
+ name: "FK_AspNetUserLogins_AspNetUsers_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetUserRoles",
+ columns: table => new
+ {
+ UserId = table.Column<Guid>(type: "uuid", nullable: false),
+ RoleId = table.Column<Guid>(type: "uuid", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
+ table.ForeignKey(
+ name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
+ column: x => x.RoleId,
+ principalTable: "AspNetRoles",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_AspNetUserRoles_AspNetUsers_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetUserTokens",
+ columns: table => new
+ {
+ UserId = table.Column<Guid>(type: "uuid", nullable: false),
+ LoginProvider = table.Column<string>(type: "text", nullable: false),
+ Name = table.Column<string>(type: "text", nullable: false),
+ Value = table.Column<string>(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
+ table.ForeignKey(
+ name: "FK_AspNetUserTokens_AspNetUsers_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "RoleUser",
+ columns: table => new
+ {
+ RolesId = table.Column<Guid>(type: "uuid", nullable: false),
+ UsersId = table.Column<Guid>(type: "uuid", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_RoleUser", x => new { x.RolesId, x.UsersId });
+ table.ForeignKey(
+ name: "FK_RoleUser_AspNetRoles_RolesId",
+ column: x => x.RolesId,
+ principalTable: "AspNetRoles",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_RoleUser_AspNetUsers_UsersId",
+ column: x => x.UsersId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "LanguageUser",
+ columns: table => new
+ {
+ LanguagesId = table.Column<Guid>(type: "uuid", nullable: false),
+ UsersId = table.Column<Guid>(type: "uuid", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_LanguageUser", x => new { x.LanguagesId, x.UsersId });
+ table.ForeignKey(
+ name: "FK_LanguageUser_AspNetUsers_UsersId",
+ column: x => x.UsersId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_LanguageUser_Languages_LanguagesId",
+ column: x => x.LanguagesId,
+ principalTable: "Languages",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Comments",
+ columns: table => new
+ {
+ Id = table.Column<Guid>(type: "uuid", nullable: false),
+ PostId = table.Column<Guid>(type: "uuid", nullable: false),
+ CreatorId = table.Column<Guid>(type: "uuid", nullable: false),
+ Message = table.Column<string>(type: "text", nullable: true),
+ TimeCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Comments", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Comments_Posts_PostId",
+ column: x => x.PostId,
+ principalTable: "Posts",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "TechnologyUser",
+ columns: table => new
+ {
+ TechnologiesId = table.Column<Guid>(type: "uuid", nullable: false),
+ UsersId = table.Column<Guid>(type: "uuid", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_TechnologyUser", x => new { x.TechnologiesId, x.UsersId });
+ table.ForeignKey(
+ name: "FK_TechnologyUser_AspNetUsers_UsersId",
+ column: x => x.UsersId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_TechnologyUser_Technologies_TechnologiesId",
+ column: x => x.TechnologiesId,
+ principalTable: "Technologies",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AspNetRoleClaims_RoleId",
+ table: "AspNetRoleClaims",
+ column: "RoleId");
+
+ migrationBuilder.CreateIndex(
+ name: "RoleNameIndex",
+ table: "AspNetRoles",
+ column: "NormalizedName",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AspNetUserClaims_UserId",
+ table: "AspNetUserClaims",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AspNetUserLogins_UserId",
+ table: "AspNetUserLogins",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AspNetUserRoles_RoleId",
+ table: "AspNetUserRoles",
+ column: "RoleId");
+
+ migrationBuilder.CreateIndex(
+ name: "EmailIndex",
+ table: "AspNetUsers",
+ column: "NormalizedEmail");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AspNetUsers_UserId",
+ table: "AspNetUsers",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AspNetUsers_UserName",
+ table: "AspNetUsers",
+ column: "UserName",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "UserNameIndex",
+ table: "AspNetUsers",
+ column: "NormalizedUserName",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Comments_PostId",
+ table: "Comments",
+ column: "PostId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_LanguageUser_UsersId",
+ table: "LanguageUser",
+ column: "UsersId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_RoleUser_UsersId",
+ table: "RoleUser",
+ column: "UsersId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_TechnologyUser_UsersId",
+ table: "TechnologyUser",
+ column: "UsersId");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "AspNetRoleClaims");
+
+ migrationBuilder.DropTable(
+ name: "AspNetUserClaims");
+
+ migrationBuilder.DropTable(
+ name: "AspNetUserLogins");
+
+ migrationBuilder.DropTable(
+ name: "AspNetUserRoles");
+
+ migrationBuilder.DropTable(
+ name: "AspNetUserTokens");
+
+ migrationBuilder.DropTable(
+ name: "Comments");
+
+ migrationBuilder.DropTable(
+ name: "LanguageUser");
+
+ migrationBuilder.DropTable(
+ name: "RoleUser");
+
+ migrationBuilder.DropTable(
+ name: "TechnologyUser");
+
+ migrationBuilder.DropTable(
+ name: "Posts");
+
+ migrationBuilder.DropTable(
+ name: "Languages");
+
+ migrationBuilder.DropTable(
+ name: "AspNetRoles");
+
+ migrationBuilder.DropTable(
+ name: "AspNetUsers");
+
+ migrationBuilder.DropTable(
+ name: "Technologies");
+ }
+ }
+}
diff --git a/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs b/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs
index 0727d33..755c274 100644
--- a/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs
+++ b/src/DevHive.Data/Migrations/DevHiveContextModelSnapshot.cs
@@ -25,13 +25,13 @@ namespace DevHive.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
- b.Property<Guid>("IssuerId")
+ b.Property<Guid>("CreatorId")
.HasColumnType("uuid");
b.Property<string>("Message")
.HasColumnType("text");
- b.Property<Guid?>("PostId")
+ b.Property<Guid>("PostId")
.HasColumnType("uuid");
b.Property<DateTime>("TimeCreated")
@@ -64,7 +64,7 @@ namespace DevHive.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
- b.Property<Guid>("IssuerId")
+ b.Property<Guid>("CreatorId")
.HasColumnType("uuid");
b.Property<string>("Message")
@@ -351,7 +351,9 @@ namespace DevHive.Data.Migrations
{
b.HasOne("DevHive.Data.Models.Post", null)
.WithMany("Comments")
- .HasForeignKey("PostId");
+ .HasForeignKey("PostId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
});
modelBuilder.Entity("DevHive.Data.Models.User", b =>
diff --git a/src/DevHive.Data/Models/Comment.cs b/src/DevHive.Data/Models/Comment.cs
index 5f4207d..c953355 100644
--- a/src/DevHive.Data/Models/Comment.cs
+++ b/src/DevHive.Data/Models/Comment.cs
@@ -9,7 +9,7 @@ namespace DevHive.Data.Models
public Guid PostId { get; set; }
- public Guid IssuerId { get; set; }
+ public Guid CreatorId { get; set; }
public string Message { get; set; }
diff --git a/src/DevHive.Data/Models/Language.cs b/src/DevHive.Data/Models/Language.cs
index f2b2786..7ad8ff2 100644
--- a/src/DevHive.Data/Models/Language.cs
+++ b/src/DevHive.Data/Models/Language.cs
@@ -7,7 +7,9 @@ namespace DevHive.Data.Models
public class Language : ILanguage
{
public Guid Id { get; set; }
+
public string Name { get; set; }
- public HashSet<User> Users { get; set; }
+
+ public HashSet<User> Users { get; set; } = new();
}
}
diff --git a/src/DevHive.Data/Models/Post.cs b/src/DevHive.Data/Models/Post.cs
index f7bca43..1b1ec4d 100644
--- a/src/DevHive.Data/Models/Post.cs
+++ b/src/DevHive.Data/Models/Post.cs
@@ -16,8 +16,8 @@ namespace DevHive.Data.Models
public DateTime TimeCreated { get; set; }
- public List<Comment> Comments { get; set; }
+ public List<Comment> Comments { get; set; } = new();
- // public List<string> Files { get; set; }
+ // public List<string> Files { get; set; } = new();
}
}
diff --git a/src/DevHive.Data/Models/Role.cs b/src/DevHive.Data/Models/Role.cs
index e0855aa..259d867 100644
--- a/src/DevHive.Data/Models/Role.cs
+++ b/src/DevHive.Data/Models/Role.cs
@@ -12,6 +12,6 @@ namespace DevHive.Data.Models
public const string DefaultRole = "User";
public const string AdminRole = "Admin";
- public HashSet<User> Users { get; set; }
+ public HashSet<User> Users { get; set; } = new();
}
}
diff --git a/src/DevHive.Data/Models/Technology.cs b/src/DevHive.Data/Models/Technology.cs
index a0728d5..6f98f0b 100644
--- a/src/DevHive.Data/Models/Technology.cs
+++ b/src/DevHive.Data/Models/Technology.cs
@@ -7,7 +7,9 @@ namespace DevHive.Data.Models
public class Technology : ITechnology
{
public Guid Id { get; set; }
+
public string Name { get; set; }
- public HashSet<User> Users { get; set; }
+
+ public HashSet<User> Users { get; set; } = new();
}
}
diff --git a/src/DevHive.Data/Models/User.cs b/src/DevHive.Data/Models/User.cs
index 2ac7adf..df440d5 100644
--- a/src/DevHive.Data/Models/User.cs
+++ b/src/DevHive.Data/Models/User.cs
@@ -19,15 +19,15 @@ namespace DevHive.Data.Models
/// Languages that the user uses or is familiar with
/// </summary>
// [Unique]
- public HashSet<Language> Languages { get; set; }
+ public HashSet<Language> Languages { get; set; } = new();
/// <summary>
/// Technologies that the user uses or is familiar with
/// </summary>
- public HashSet<Technology> Technologies { get; set; } = new HashSet<Technology>();
+ public HashSet<Technology> Technologies { get; set; } = new();
- public HashSet<Role> Roles { get; set; } = new HashSet<Role>();
+ public HashSet<Role> Roles { get; set; } = new();
- public HashSet<User> Friends { get; set; } = new HashSet<User>();
+ public HashSet<User> Friends { get; set; } = new();
}
}
diff --git a/src/DevHive.Data/Repositories/CommentRepository.cs b/src/DevHive.Data/Repositories/CommentRepository.cs
index 880631a..006326a 100644
--- a/src/DevHive.Data/Repositories/CommentRepository.cs
+++ b/src/DevHive.Data/Repositories/CommentRepository.cs
@@ -20,7 +20,7 @@ namespace DevHive.Data.Repositories
public async Task<Comment> GetCommentByIssuerAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated)
{
return await this._context.Comments
- .FirstOrDefaultAsync(p => p.IssuerId == issuerId &&
+ .FirstOrDefaultAsync(p => p.CreatorId == issuerId &&
p.TimeCreated == timeCreated);
}
#endregion
diff --git a/src/DevHive.Data/Repositories/PostRepository.cs b/src/DevHive.Data/Repositories/PostRepository.cs
index a79eacf..e8180de 100644
--- a/src/DevHive.Data/Repositories/PostRepository.cs
+++ b/src/DevHive.Data/Repositories/PostRepository.cs
@@ -17,6 +17,13 @@ namespace DevHive.Data.Repositories
}
#region Read
+ public override async Task<Post> GetByIdAsync(Guid id)
+ {
+ return await this._context.Posts
+ .Include(x => x.Comments)
+ .FirstOrDefaultAsync(x => x.Id == id);
+ }
+
public async Task<Post> GetPostByCreatorAndTimeCreatedAsync(Guid creatorId, DateTime timeCreated)
{
return await this._context.Posts