aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Web/Migrations/20201217083429_UserRoleTest.cs
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-12-17 11:21:14 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-12-17 11:21:14 +0200
commit5811d878180a85af5c41b9cb3b8f272d589539e9 (patch)
tree16c27c0c797f004d20634e29d1752c994386537d /src/DevHive.Web/Migrations/20201217083429_UserRoleTest.cs
parentedf40b339c999c936d0e022100d67c853cd1b792 (diff)
downloadDevHive-5811d878180a85af5c41b9cb3b8f272d589539e9.tar
DevHive-5811d878180a85af5c41b9cb3b8f272d589539e9.tar.gz
DevHive-5811d878180a85af5c41b9cb3b8f272d589539e9.zip
Roles are now in a seperate table, user can contain multiple roles (BUT JWT doesn't support mutiple yet), added migrations, userrepository returns user roles with the user
Diffstat (limited to 'src/DevHive.Web/Migrations/20201217083429_UserRoleTest.cs')
-rw-r--r--src/DevHive.Web/Migrations/20201217083429_UserRoleTest.cs134
1 files changed, 134 insertions, 0 deletions
diff --git a/src/DevHive.Web/Migrations/20201217083429_UserRoleTest.cs b/src/DevHive.Web/Migrations/20201217083429_UserRoleTest.cs
new file mode 100644
index 0000000..7c8e77a
--- /dev/null
+++ b/src/DevHive.Web/Migrations/20201217083429_UserRoleTest.cs
@@ -0,0 +1,134 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace DevHive.Web.Migrations
+{
+ public partial class UserRoleTest : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Role",
+ table: "AspNetUsers");
+
+ migrationBuilder.AddColumn<string>(
+ name: "Name",
+ table: "Technologies",
+ type: "text",
+ nullable: true);
+
+ migrationBuilder.AlterColumn<string>(
+ name: "UserName",
+ table: "AspNetUsers",
+ type: "character varying(256)",
+ maxLength: 256,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "character varying(256)",
+ oldMaxLength: 256);
+
+ migrationBuilder.AlterColumn<string>(
+ name: "LastName",
+ table: "AspNetUsers",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+
+ migrationBuilder.AlterColumn<string>(
+ name: "FirstName",
+ table: "AspNetUsers",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+
+ 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.CreateIndex(
+ name: "IX_AspNetRoles_Id",
+ table: "AspNetRoles",
+ column: "Id",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_RoleUser_UsersId",
+ table: "RoleUser",
+ column: "UsersId");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "RoleUser");
+
+ migrationBuilder.DropIndex(
+ name: "IX_AspNetRoles_Id",
+ table: "AspNetRoles");
+
+ migrationBuilder.DropColumn(
+ name: "Name",
+ table: "Technologies");
+
+ migrationBuilder.AlterColumn<string>(
+ name: "UserName",
+ table: "AspNetUsers",
+ type: "character varying(256)",
+ maxLength: 256,
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "character varying(256)",
+ oldMaxLength: 256,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn<string>(
+ name: "LastName",
+ table: "AspNetUsers",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn<string>(
+ name: "FirstName",
+ table: "AspNetUsers",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+
+ migrationBuilder.AddColumn<string>(
+ name: "Role",
+ table: "AspNetUsers",
+ type: "text",
+ nullable: true);
+ }
+ }
+}