20240122162044_altrIdentity.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
  5. namespace MTWorkHR.Identity.Migrations
  6. {
  7. /// <inheritdoc />
  8. public partial class altrIdentity : Migration
  9. {
  10. /// <inheritdoc />
  11. protected override void Up(MigrationBuilder migrationBuilder)
  12. {
  13. migrationBuilder.DeleteData(
  14. table: "AspNetRoles",
  15. keyColumn: "Id",
  16. keyValue: "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211B");
  17. migrationBuilder.DeleteData(
  18. table: "AspNetRoles",
  19. keyColumn: "Id",
  20. keyValue: "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211A");
  21. migrationBuilder.AddColumn<string>(
  22. name: "CreateUser",
  23. table: "AspNetUsers",
  24. type: "nvarchar(max)",
  25. nullable: true);
  26. migrationBuilder.AddColumn<string>(
  27. name: "DeleteUserId",
  28. table: "AspNetUsers",
  29. type: "nvarchar(max)",
  30. nullable: true);
  31. migrationBuilder.AddColumn<bool>(
  32. name: "IsDeleted",
  33. table: "AspNetUsers",
  34. type: "bit",
  35. nullable: false,
  36. defaultValue: false);
  37. migrationBuilder.AddColumn<bool>(
  38. name: "IsStopped",
  39. table: "AspNetUsers",
  40. type: "bit",
  41. nullable: false,
  42. defaultValue: false);
  43. migrationBuilder.AddColumn<string>(
  44. name: "ManagerId",
  45. table: "AspNetUsers",
  46. type: "nvarchar(450)",
  47. nullable: true);
  48. migrationBuilder.AddColumn<string>(
  49. name: "UpdateUser",
  50. table: "AspNetUsers",
  51. type: "nvarchar(max)",
  52. nullable: true);
  53. migrationBuilder.AddColumn<int>(
  54. name: "UserType",
  55. table: "AspNetUsers",
  56. type: "int",
  57. nullable: false,
  58. defaultValue: 0);
  59. migrationBuilder.AddColumn<DateTime>(
  60. name: "CreateDate",
  61. table: "AspNetRoles",
  62. type: "datetime2",
  63. nullable: false,
  64. defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
  65. migrationBuilder.AddColumn<string>(
  66. name: "CreateUser",
  67. table: "AspNetRoles",
  68. type: "nvarchar(max)",
  69. nullable: true);
  70. migrationBuilder.AddColumn<string>(
  71. name: "DeleteUserId",
  72. table: "AspNetRoles",
  73. type: "nvarchar(max)",
  74. nullable: true);
  75. migrationBuilder.AddColumn<bool>(
  76. name: "IsAdmin",
  77. table: "AspNetRoles",
  78. type: "bit",
  79. nullable: true);
  80. migrationBuilder.AddColumn<bool>(
  81. name: "IsDeleted",
  82. table: "AspNetRoles",
  83. type: "bit",
  84. nullable: false,
  85. defaultValue: false);
  86. migrationBuilder.AddColumn<DateTime>(
  87. name: "UpdateDate",
  88. table: "AspNetRoles",
  89. type: "datetime2",
  90. nullable: true);
  91. migrationBuilder.AddColumn<string>(
  92. name: "UpdateUser",
  93. table: "AspNetRoles",
  94. type: "nvarchar(max)",
  95. nullable: true);
  96. migrationBuilder.CreateTable(
  97. name: "ApplicationRoleApplicationUser",
  98. columns: table => new
  99. {
  100. UserRolesId = table.Column<string>(type: "nvarchar(450)", nullable: false),
  101. UsersId = table.Column<string>(type: "nvarchar(450)", nullable: false)
  102. },
  103. constraints: table =>
  104. {
  105. table.PrimaryKey("PK_ApplicationRoleApplicationUser", x => new { x.UserRolesId, x.UsersId });
  106. table.ForeignKey(
  107. name: "FK_ApplicationRoleApplicationUser_AspNetRoles_UserRolesId",
  108. column: x => x.UserRolesId,
  109. principalTable: "AspNetRoles",
  110. principalColumn: "Id",
  111. onDelete: ReferentialAction.Cascade);
  112. table.ForeignKey(
  113. name: "FK_ApplicationRoleApplicationUser_AspNetUsers_UsersId",
  114. column: x => x.UsersId,
  115. principalTable: "AspNetUsers",
  116. principalColumn: "Id",
  117. onDelete: ReferentialAction.Cascade);
  118. });
  119. migrationBuilder.CreateTable(
  120. name: "IdentityRole",
  121. columns: table => new
  122. {
  123. Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
  124. Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
  125. NormalizedName = table.Column<string>(type: "nvarchar(max)", nullable: true),
  126. ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true)
  127. },
  128. constraints: table =>
  129. {
  130. table.PrimaryKey("PK_IdentityRole", x => x.Id);
  131. });
  132. migrationBuilder.CreateTable(
  133. name: "Permissions",
  134. columns: table => new
  135. {
  136. Id = table.Column<long>(type: "bigint", nullable: false)
  137. .Annotation("SqlServer:Identity", "1, 1"),
  138. Name = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  139. CategoryName = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false),
  140. Desc = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  141. Show = table.Column<bool>(type: "bit", nullable: false)
  142. },
  143. constraints: table =>
  144. {
  145. table.PrimaryKey("PK_Permissions", x => x.Id);
  146. });
  147. migrationBuilder.CreateTable(
  148. name: "RolePermissions",
  149. columns: table => new
  150. {
  151. Id = table.Column<long>(type: "bigint", nullable: false)
  152. .Annotation("SqlServer:Identity", "1, 1"),
  153. RoleId = table.Column<string>(type: "nvarchar(450)", nullable: false),
  154. PermissionId = table.Column<long>(type: "bigint", nullable: false),
  155. PermissionName = table.Column<string>(type: "nvarchar(max)", nullable: false)
  156. },
  157. constraints: table =>
  158. {
  159. table.PrimaryKey("PK_RolePermissions", x => x.Id);
  160. table.ForeignKey(
  161. name: "FK_RolePermissions_AspNetRoles_RoleId",
  162. column: x => x.RoleId,
  163. principalTable: "AspNetRoles",
  164. principalColumn: "Id",
  165. onDelete: ReferentialAction.Cascade);
  166. table.ForeignKey(
  167. name: "FK_RolePermissions_Permissions_PermissionId",
  168. column: x => x.PermissionId,
  169. principalTable: "Permissions",
  170. principalColumn: "Id",
  171. onDelete: ReferentialAction.Cascade);
  172. });
  173. migrationBuilder.UpdateData(
  174. table: "AspNetUsers",
  175. keyColumn: "Id",
  176. keyValue: "AD5B3B92-2311-48F8-9DEC-F9FAEF1F21UA",
  177. columns: new[] { "ConcurrencyStamp", "CreateUser", "DeleteUserId", "IsDeleted", "IsStopped", "ManagerId", "SecurityStamp", "UpdateUser", "UserType" },
  178. values: new object[] { "b6b32734-b83c-4619-8de6-6e0e48cea904", null, null, false, false, null, "2ec2e41b-9f51-4779-9687-4cef7afd2c98", null, 1 });
  179. migrationBuilder.UpdateData(
  180. table: "AspNetUsers",
  181. keyColumn: "Id",
  182. keyValue: "LL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",
  183. columns: new[] { "ConcurrencyStamp", "CreateUser", "DeleteUserId", "IsDeleted", "IsStopped", "ManagerId", "SecurityStamp", "UpdateUser", "UserType" },
  184. values: new object[] { "f3684ce0-8dc7-4f91-b317-b6a7d8d55011", null, null, false, false, null, "50a3c8b2-93bf-41b3-bf7f-d2240d8b7386", null, 1 });
  185. migrationBuilder.InsertData(
  186. table: "IdentityRole",
  187. columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
  188. values: new object[,]
  189. {
  190. { "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211B", null, "Admin", "ADMIN" },
  191. { "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211A", null, "Employee", "EMPLOYEE" }
  192. });
  193. migrationBuilder.CreateIndex(
  194. name: "IX_AspNetUsers_ManagerId",
  195. table: "AspNetUsers",
  196. column: "ManagerId");
  197. migrationBuilder.CreateIndex(
  198. name: "IX_ApplicationRoleApplicationUser_UsersId",
  199. table: "ApplicationRoleApplicationUser",
  200. column: "UsersId");
  201. migrationBuilder.CreateIndex(
  202. name: "IX_RolePermissions_PermissionId",
  203. table: "RolePermissions",
  204. column: "PermissionId");
  205. migrationBuilder.CreateIndex(
  206. name: "IX_RolePermissions_RoleId",
  207. table: "RolePermissions",
  208. column: "RoleId");
  209. migrationBuilder.AddForeignKey(
  210. name: "FK_AspNetUsers_AspNetUsers_ManagerId",
  211. table: "AspNetUsers",
  212. column: "ManagerId",
  213. principalTable: "AspNetUsers",
  214. principalColumn: "Id");
  215. }
  216. /// <inheritdoc />
  217. protected override void Down(MigrationBuilder migrationBuilder)
  218. {
  219. migrationBuilder.DropForeignKey(
  220. name: "FK_AspNetUsers_AspNetUsers_ManagerId",
  221. table: "AspNetUsers");
  222. migrationBuilder.DropTable(
  223. name: "ApplicationRoleApplicationUser");
  224. migrationBuilder.DropTable(
  225. name: "IdentityRole");
  226. migrationBuilder.DropTable(
  227. name: "RolePermissions");
  228. migrationBuilder.DropTable(
  229. name: "Permissions");
  230. migrationBuilder.DropIndex(
  231. name: "IX_AspNetUsers_ManagerId",
  232. table: "AspNetUsers");
  233. migrationBuilder.DropColumn(
  234. name: "CreateUser",
  235. table: "AspNetUsers");
  236. migrationBuilder.DropColumn(
  237. name: "DeleteUserId",
  238. table: "AspNetUsers");
  239. migrationBuilder.DropColumn(
  240. name: "IsDeleted",
  241. table: "AspNetUsers");
  242. migrationBuilder.DropColumn(
  243. name: "IsStopped",
  244. table: "AspNetUsers");
  245. migrationBuilder.DropColumn(
  246. name: "ManagerId",
  247. table: "AspNetUsers");
  248. migrationBuilder.DropColumn(
  249. name: "UpdateUser",
  250. table: "AspNetUsers");
  251. migrationBuilder.DropColumn(
  252. name: "UserType",
  253. table: "AspNetUsers");
  254. migrationBuilder.DropColumn(
  255. name: "CreateDate",
  256. table: "AspNetRoles");
  257. migrationBuilder.DropColumn(
  258. name: "CreateUser",
  259. table: "AspNetRoles");
  260. migrationBuilder.DropColumn(
  261. name: "DeleteUserId",
  262. table: "AspNetRoles");
  263. migrationBuilder.DropColumn(
  264. name: "IsAdmin",
  265. table: "AspNetRoles");
  266. migrationBuilder.DropColumn(
  267. name: "IsDeleted",
  268. table: "AspNetRoles");
  269. migrationBuilder.DropColumn(
  270. name: "UpdateDate",
  271. table: "AspNetRoles");
  272. migrationBuilder.DropColumn(
  273. name: "UpdateUser",
  274. table: "AspNetRoles");
  275. migrationBuilder.InsertData(
  276. table: "AspNetRoles",
  277. columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
  278. values: new object[,]
  279. {
  280. { "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211B", null, "Admin", "ADMIN" },
  281. { "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211A", null, "Employee", "EMPLOYEE" }
  282. });
  283. migrationBuilder.UpdateData(
  284. table: "AspNetUsers",
  285. keyColumn: "Id",
  286. keyValue: "AD5B3B92-2311-48F8-9DEC-F9FAEF1F21UA",
  287. columns: new[] { "ConcurrencyStamp", "SecurityStamp" },
  288. values: new object[] { "d1e41737-1312-47fe-b7e9-fa9917dd94ad", "7714198f-15f6-4524-a221-b0826892516b" });
  289. migrationBuilder.UpdateData(
  290. table: "AspNetUsers",
  291. keyColumn: "Id",
  292. keyValue: "LL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",
  293. columns: new[] { "ConcurrencyStamp", "SecurityStamp" },
  294. values: new object[] { "fe634cad-b63a-4cc1-8938-4499edd22d35", "bba3264c-1777-4ca7-837a-2f8ed1b16d01" });
  295. }
  296. }
  297. }