|
@@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|
namespace MTWorkHR.Identity.Migrations
|
|
namespace MTWorkHR.Identity.Migrations
|
|
{
|
|
{
|
|
/// <inheritdoc />
|
|
/// <inheritdoc />
|
|
- public partial class identity : Migration
|
|
|
|
|
|
+ public partial class InitialCreate : Migration
|
|
{
|
|
{
|
|
/// <inheritdoc />
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
@@ -18,6 +18,13 @@ namespace MTWorkHR.Identity.Migrations
|
|
columns: table => new
|
|
columns: table => new
|
|
{
|
|
{
|
|
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
|
|
+ CreateUser = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
|
|
+ UpdateUser = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
|
|
+ CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
|
|
+ UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
|
|
+ IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
|
|
|
+ DeleteUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
|
|
+ IsAdmin = table.Column<bool>(type: "bit", nullable: true),
|
|
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
NormalizedName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
NormalizedName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
@@ -34,6 +41,13 @@ namespace MTWorkHR.Identity.Migrations
|
|
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
+ UserType = table.Column<int>(type: "int", nullable: false),
|
|
|
|
+ ManagerId = table.Column<string>(type: "nvarchar(450)", nullable: true),
|
|
|
|
+ CreateUser = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
|
|
+ UpdateUser = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
|
|
+ IsStopped = table.Column<bool>(type: "bit", nullable: false),
|
|
|
|
+ IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
|
|
|
+ DeleteUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
NormalizedUserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
NormalizedUserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
@@ -52,6 +66,27 @@ namespace MTWorkHR.Identity.Migrations
|
|
constraints: table =>
|
|
constraints: table =>
|
|
{
|
|
{
|
|
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
|
|
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
|
|
|
|
+ table.ForeignKey(
|
|
|
|
+ name: "FK_AspNetUsers_AspNetUsers_ManagerId",
|
|
|
|
+ column: x => x.ManagerId,
|
|
|
|
+ principalTable: "AspNetUsers",
|
|
|
|
+ principalColumn: "Id");
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ migrationBuilder.CreateTable(
|
|
|
|
+ name: "Permissions",
|
|
|
|
+ columns: table => new
|
|
|
|
+ {
|
|
|
|
+ Id = table.Column<long>(type: "bigint", nullable: false)
|
|
|
|
+ .Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
+ Name = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
|
|
|
|
+ CategoryName = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false),
|
|
|
|
+ Desc = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
|
|
|
|
+ Show = table.Column<bool>(type: "bit", nullable: false)
|
|
|
|
+ },
|
|
|
|
+ constraints: table =>
|
|
|
|
+ {
|
|
|
|
+ table.PrimaryKey("PK_Permissions", x => x.Id);
|
|
});
|
|
});
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
migrationBuilder.CreateTable(
|
|
@@ -76,6 +111,30 @@ namespace MTWorkHR.Identity.Migrations
|
|
});
|
|
});
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
migrationBuilder.CreateTable(
|
|
|
|
+ name: "ApplicationRoleApplicationUser",
|
|
|
|
+ columns: table => new
|
|
|
|
+ {
|
|
|
|
+ UserRolesId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
|
|
+ UsersId = table.Column<string>(type: "nvarchar(450)", nullable: false)
|
|
|
|
+ },
|
|
|
|
+ constraints: table =>
|
|
|
|
+ {
|
|
|
|
+ table.PrimaryKey("PK_ApplicationRoleApplicationUser", x => new { x.UserRolesId, x.UsersId });
|
|
|
|
+ table.ForeignKey(
|
|
|
|
+ name: "FK_ApplicationRoleApplicationUser_AspNetRoles_UserRolesId",
|
|
|
|
+ column: x => x.UserRolesId,
|
|
|
|
+ principalTable: "AspNetRoles",
|
|
|
|
+ principalColumn: "Id",
|
|
|
|
+ onDelete: ReferentialAction.Cascade);
|
|
|
|
+ table.ForeignKey(
|
|
|
|
+ name: "FK_ApplicationRoleApplicationUser_AspNetUsers_UsersId",
|
|
|
|
+ column: x => x.UsersId,
|
|
|
|
+ principalTable: "AspNetUsers",
|
|
|
|
+ principalColumn: "Id",
|
|
|
|
+ onDelete: ReferentialAction.Cascade);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ migrationBuilder.CreateTable(
|
|
name: "AspNetUserClaims",
|
|
name: "AspNetUserClaims",
|
|
columns: table => new
|
|
columns: table => new
|
|
{
|
|
{
|
|
@@ -160,22 +219,49 @@ namespace MTWorkHR.Identity.Migrations
|
|
onDelete: ReferentialAction.Cascade);
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ migrationBuilder.CreateTable(
|
|
|
|
+ name: "RolePermissions",
|
|
|
|
+ columns: table => new
|
|
|
|
+ {
|
|
|
|
+ Id = table.Column<long>(type: "bigint", nullable: false)
|
|
|
|
+ .Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
+ RoleId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
|
|
+ PermissionId = table.Column<long>(type: "bigint", nullable: false),
|
|
|
|
+ PermissionName = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
|
|
+ },
|
|
|
|
+ constraints: table =>
|
|
|
|
+ {
|
|
|
|
+ table.PrimaryKey("PK_RolePermissions", x => x.Id);
|
|
|
|
+ table.ForeignKey(
|
|
|
|
+ name: "FK_RolePermissions_AspNetRoles_RoleId",
|
|
|
|
+ column: x => x.RoleId,
|
|
|
|
+ principalTable: "AspNetRoles",
|
|
|
|
+ principalColumn: "Id",
|
|
|
|
+ onDelete: ReferentialAction.Cascade);
|
|
|
|
+ table.ForeignKey(
|
|
|
|
+ name: "FK_RolePermissions_Permissions_PermissionId",
|
|
|
|
+ column: x => x.PermissionId,
|
|
|
|
+ principalTable: "Permissions",
|
|
|
|
+ principalColumn: "Id",
|
|
|
|
+ onDelete: ReferentialAction.Cascade);
|
|
|
|
+ });
|
|
|
|
+
|
|
migrationBuilder.InsertData(
|
|
migrationBuilder.InsertData(
|
|
table: "AspNetRoles",
|
|
table: "AspNetRoles",
|
|
- columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
|
|
|
|
|
|
+ columns: new[] { "Id", "ConcurrencyStamp", "CreateDate", "CreateUser", "DeleteUserId", "IsAdmin", "IsDeleted", "Name", "NormalizedName", "UpdateDate", "UpdateUser" },
|
|
values: new object[,]
|
|
values: new object[,]
|
|
{
|
|
{
|
|
- { "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211B", null, "Admin", "ADMIN" },
|
|
|
|
- { "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211A", null, "Employee", "EMPLOYEE" }
|
|
|
|
|
|
+ { "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211A", null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, null, true, false, "Admin", "ADMIN", null, null },
|
|
|
|
+ { "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, null, false, false, "Employee", "EMPLOYEE", null, null }
|
|
});
|
|
});
|
|
|
|
|
|
migrationBuilder.InsertData(
|
|
migrationBuilder.InsertData(
|
|
table: "AspNetUsers",
|
|
table: "AspNetUsers",
|
|
- columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Email", "EmailConfirmed", "FirstName", "LastName", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName" },
|
|
|
|
|
|
+ columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "CreateUser", "DeleteUserId", "Email", "EmailConfirmed", "FirstName", "IsDeleted", "IsStopped", "LastName", "LockoutEnabled", "LockoutEnd", "ManagerId", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UpdateUser", "UserName", "UserType" },
|
|
values: new object[,]
|
|
values: new object[,]
|
|
{
|
|
{
|
|
- { "AD5B3B92-2311-48F8-9DEC-F9FAEF1F21UA", 0, "d1e41737-1312-47fe-b7e9-fa9917dd94ad", "a@b.com", true, "Zinab", "Elgendy", false, null, "A@B.COM", "ADMIN", "AQAAAAIAAYagAAAAEPg+ASbciPFxtyxQq8Wx5ilBUQ0RbAoITXXkOQm1PzC5BzySX0sn/wUmOjBKPDGV9w==", "1234567890", true, "7714198f-15f6-4524-a221-b0826892516b", false, "Admin" },
|
|
|
|
- { "LL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB", 0, "fe634cad-b63a-4cc1-8938-4499edd22d35", "ali@b.com", true, "Ali", "Farok", false, null, "ALI@B.COM", "ALI", "AQAAAAIAAYagAAAAEI3QJkcZjCH4Y8Db4rEgL8Mmll5oCvYcWiXZjQSN9bGW4SMcjHe3ZPMnkN/l9DmJeQ==", "1234567890", true, "bba3264c-1777-4ca7-837a-2f8ed1b16d01", false, "ali" }
|
|
|
|
|
|
+ { "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA", 0, "7cc87689-9eab-4280-b8e3-1834080783a5", null, null, "a@b.com", true, "Zinab", false, false, "Elgendy", false, null, null, "A@B.COM", "ADMIN", "AQAAAAIAAYagAAAAEPg+ASbciPFxtyxQq8Wx5ilBUQ0RbAoITXXkOQm1PzC5BzySX0sn/wUmOjBKPDGV9w==", "1234567890", true, "49bb16c3-4704-4c60-908d-dc8506950acc", false, null, "Admin", 1 },
|
|
|
|
+ { "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB", 0, "4af7b4cf-802a-455b-b598-997e167745b3", null, null, "ali@b.com", true, "Ali", false, false, "Farok", false, null, null, "ALI@B.COM", "ALI", "AQAAAAIAAYagAAAAEI3QJkcZjCH4Y8Db4rEgL8Mmll5oCvYcWiXZjQSN9bGW4SMcjHe3ZPMnkN/l9DmJeQ==", "1234567890", true, "62549056-1b9d-46d4-84f8-adea3e4d8b68", false, null, "ali", 1 }
|
|
});
|
|
});
|
|
|
|
|
|
migrationBuilder.InsertData(
|
|
migrationBuilder.InsertData(
|
|
@@ -183,11 +269,16 @@ namespace MTWorkHR.Identity.Migrations
|
|
columns: new[] { "RoleId", "UserId" },
|
|
columns: new[] { "RoleId", "UserId" },
|
|
values: new object[,]
|
|
values: new object[,]
|
|
{
|
|
{
|
|
- { "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211B", "AD5B3B92-2311-48F8-9DEC-F9FAEF1F21UA" },
|
|
|
|
- { "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211A", "LL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB" }
|
|
|
|
|
|
+ { "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211A", "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA" },
|
|
|
|
+ { "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB" }
|
|
});
|
|
});
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
migrationBuilder.CreateIndex(
|
|
|
|
+ name: "IX_ApplicationRoleApplicationUser_UsersId",
|
|
|
|
+ table: "ApplicationRoleApplicationUser",
|
|
|
|
+ column: "UsersId");
|
|
|
|
+
|
|
|
|
+ migrationBuilder.CreateIndex(
|
|
name: "IX_AspNetRoleClaims_RoleId",
|
|
name: "IX_AspNetRoleClaims_RoleId",
|
|
table: "AspNetRoleClaims",
|
|
table: "AspNetRoleClaims",
|
|
column: "RoleId");
|
|
column: "RoleId");
|
|
@@ -220,17 +311,35 @@ namespace MTWorkHR.Identity.Migrations
|
|
column: "NormalizedEmail");
|
|
column: "NormalizedEmail");
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
migrationBuilder.CreateIndex(
|
|
|
|
+ name: "IX_AspNetUsers_ManagerId",
|
|
|
|
+ table: "AspNetUsers",
|
|
|
|
+ column: "ManagerId");
|
|
|
|
+
|
|
|
|
+ migrationBuilder.CreateIndex(
|
|
name: "UserNameIndex",
|
|
name: "UserNameIndex",
|
|
table: "AspNetUsers",
|
|
table: "AspNetUsers",
|
|
column: "NormalizedUserName",
|
|
column: "NormalizedUserName",
|
|
unique: true,
|
|
unique: true,
|
|
filter: "[NormalizedUserName] IS NOT NULL");
|
|
filter: "[NormalizedUserName] IS NOT NULL");
|
|
|
|
+
|
|
|
|
+ migrationBuilder.CreateIndex(
|
|
|
|
+ name: "IX_RolePermissions_PermissionId",
|
|
|
|
+ table: "RolePermissions",
|
|
|
|
+ column: "PermissionId");
|
|
|
|
+
|
|
|
|
+ migrationBuilder.CreateIndex(
|
|
|
|
+ name: "IX_RolePermissions_RoleId",
|
|
|
|
+ table: "RolePermissions",
|
|
|
|
+ column: "RoleId");
|
|
}
|
|
}
|
|
|
|
|
|
/// <inheritdoc />
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
{
|
|
migrationBuilder.DropTable(
|
|
migrationBuilder.DropTable(
|
|
|
|
+ name: "ApplicationRoleApplicationUser");
|
|
|
|
+
|
|
|
|
+ migrationBuilder.DropTable(
|
|
name: "AspNetRoleClaims");
|
|
name: "AspNetRoleClaims");
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
migrationBuilder.DropTable(
|
|
@@ -246,10 +355,16 @@ namespace MTWorkHR.Identity.Migrations
|
|
name: "AspNetUserTokens");
|
|
name: "AspNetUserTokens");
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
migrationBuilder.DropTable(
|
|
- name: "AspNetRoles");
|
|
|
|
|
|
+ name: "RolePermissions");
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
migrationBuilder.DropTable(
|
|
name: "AspNetUsers");
|
|
name: "AspNetUsers");
|
|
|
|
+
|
|
|
|
+ migrationBuilder.DropTable(
|
|
|
|
+ name: "AspNetRoles");
|
|
|
|
+
|
|
|
|
+ migrationBuilder.DropTable(
|
|
|
|
+ name: "Permissions");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|