20240415223747_InitWithIdentity.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
  4. #nullable disable
  5. #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
  6. namespace OnlineMetodist.API.Migrations
  7. {
  8. /// <inheritdoc />
  9. public partial class InitWithIdentity : Migration
  10. {
  11. /// <inheritdoc />
  12. protected override void Up(MigrationBuilder migrationBuilder)
  13. {
  14. migrationBuilder.CreateTable(
  15. name: "AspNetRoles",
  16. columns: table => new
  17. {
  18. Id = table.Column<string>(type: "text", nullable: false),
  19. Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
  20. NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
  21. ConcurrencyStamp = table.Column<string>(type: "text", nullable: true)
  22. },
  23. constraints: table =>
  24. {
  25. table.PrimaryKey("PK_AspNetRoles", x => x.Id);
  26. });
  27. migrationBuilder.CreateTable(
  28. name: "AspNetUsers",
  29. columns: table => new
  30. {
  31. Id = table.Column<string>(type: "text", nullable: false),
  32. UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
  33. NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
  34. Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
  35. NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
  36. EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
  37. PasswordHash = table.Column<string>(type: "text", nullable: true),
  38. SecurityStamp = table.Column<string>(type: "text", nullable: true),
  39. ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
  40. PhoneNumber = table.Column<string>(type: "text", nullable: true),
  41. PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
  42. TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
  43. LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
  44. LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
  45. AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
  46. },
  47. constraints: table =>
  48. {
  49. table.PrimaryKey("PK_AspNetUsers", x => x.Id);
  50. });
  51. migrationBuilder.CreateTable(
  52. name: "FormsOfWorks",
  53. columns: table => new
  54. {
  55. Id = table.Column<Guid>(type: "uuid", nullable: false),
  56. Name = table.Column<string>(type: "text", nullable: false)
  57. },
  58. constraints: table =>
  59. {
  60. table.PrimaryKey("PK_FormsOfWorks", x => x.Id);
  61. });
  62. migrationBuilder.CreateTable(
  63. name: "AspNetRoleClaims",
  64. columns: table => new
  65. {
  66. Id = table.Column<int>(type: "integer", nullable: false)
  67. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
  68. RoleId = table.Column<string>(type: "text", nullable: false),
  69. ClaimType = table.Column<string>(type: "text", nullable: true),
  70. ClaimValue = table.Column<string>(type: "text", nullable: true)
  71. },
  72. constraints: table =>
  73. {
  74. table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
  75. table.ForeignKey(
  76. name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
  77. column: x => x.RoleId,
  78. principalTable: "AspNetRoles",
  79. principalColumn: "Id",
  80. onDelete: ReferentialAction.Cascade);
  81. });
  82. migrationBuilder.CreateTable(
  83. name: "AspNetUserClaims",
  84. columns: table => new
  85. {
  86. Id = table.Column<int>(type: "integer", nullable: false)
  87. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
  88. UserId = table.Column<string>(type: "text", nullable: false),
  89. ClaimType = table.Column<string>(type: "text", nullable: true),
  90. ClaimValue = table.Column<string>(type: "text", nullable: true)
  91. },
  92. constraints: table =>
  93. {
  94. table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
  95. table.ForeignKey(
  96. name: "FK_AspNetUserClaims_AspNetUsers_UserId",
  97. column: x => x.UserId,
  98. principalTable: "AspNetUsers",
  99. principalColumn: "Id",
  100. onDelete: ReferentialAction.Cascade);
  101. });
  102. migrationBuilder.CreateTable(
  103. name: "AspNetUserLogins",
  104. columns: table => new
  105. {
  106. LoginProvider = table.Column<string>(type: "text", nullable: false),
  107. ProviderKey = table.Column<string>(type: "text", nullable: false),
  108. ProviderDisplayName = table.Column<string>(type: "text", nullable: true),
  109. UserId = table.Column<string>(type: "text", nullable: false)
  110. },
  111. constraints: table =>
  112. {
  113. table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
  114. table.ForeignKey(
  115. name: "FK_AspNetUserLogins_AspNetUsers_UserId",
  116. column: x => x.UserId,
  117. principalTable: "AspNetUsers",
  118. principalColumn: "Id",
  119. onDelete: ReferentialAction.Cascade);
  120. });
  121. migrationBuilder.CreateTable(
  122. name: "AspNetUserRoles",
  123. columns: table => new
  124. {
  125. UserId = table.Column<string>(type: "text", nullable: false),
  126. RoleId = table.Column<string>(type: "text", nullable: false)
  127. },
  128. constraints: table =>
  129. {
  130. table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
  131. table.ForeignKey(
  132. name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
  133. column: x => x.RoleId,
  134. principalTable: "AspNetRoles",
  135. principalColumn: "Id",
  136. onDelete: ReferentialAction.Cascade);
  137. table.ForeignKey(
  138. name: "FK_AspNetUserRoles_AspNetUsers_UserId",
  139. column: x => x.UserId,
  140. principalTable: "AspNetUsers",
  141. principalColumn: "Id",
  142. onDelete: ReferentialAction.Cascade);
  143. });
  144. migrationBuilder.CreateTable(
  145. name: "AspNetUserTokens",
  146. columns: table => new
  147. {
  148. UserId = table.Column<string>(type: "text", nullable: false),
  149. LoginProvider = table.Column<string>(type: "text", nullable: false),
  150. Name = table.Column<string>(type: "text", nullable: false),
  151. Value = table.Column<string>(type: "text", nullable: true)
  152. },
  153. constraints: table =>
  154. {
  155. table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
  156. table.ForeignKey(
  157. name: "FK_AspNetUserTokens_AspNetUsers_UserId",
  158. column: x => x.UserId,
  159. principalTable: "AspNetUsers",
  160. principalColumn: "Id",
  161. onDelete: ReferentialAction.Cascade);
  162. });
  163. migrationBuilder.CreateTable(
  164. name: "Employees",
  165. columns: table => new
  166. {
  167. Id = table.Column<Guid>(type: "uuid", nullable: false),
  168. Surname = table.Column<string>(type: "text", nullable: false),
  169. Name = table.Column<string>(type: "text", nullable: false),
  170. Patronymic = table.Column<string>(type: "text", nullable: true),
  171. UserId = table.Column<string>(type: "text", nullable: false)
  172. },
  173. constraints: table =>
  174. {
  175. table.PrimaryKey("PK_Employees", x => x.Id);
  176. table.ForeignKey(
  177. name: "FK_Employees_AspNetUsers_UserId",
  178. column: x => x.UserId,
  179. principalTable: "AspNetUsers",
  180. principalColumn: "Id",
  181. onDelete: ReferentialAction.Cascade);
  182. });
  183. migrationBuilder.CreateTable(
  184. name: "Events",
  185. columns: table => new
  186. {
  187. Id = table.Column<Guid>(type: "uuid", nullable: false),
  188. DateOfEvent = table.Column<DateOnly>(type: "date", nullable: false),
  189. EndDateOfEvent = table.Column<DateOnly>(type: "date", nullable: true),
  190. Specifications = table.Column<string>(type: "text", nullable: false),
  191. IdFormOfWork = table.Column<Guid>(type: "uuid", nullable: false),
  192. FormOfWorkFKId = table.Column<Guid>(type: "uuid", nullable: false),
  193. EmployeeId = table.Column<Guid>(type: "uuid", nullable: true)
  194. },
  195. constraints: table =>
  196. {
  197. table.PrimaryKey("PK_Events", x => x.Id);
  198. table.ForeignKey(
  199. name: "FK_Events_Employees_EmployeeId",
  200. column: x => x.EmployeeId,
  201. principalTable: "Employees",
  202. principalColumn: "Id");
  203. table.ForeignKey(
  204. name: "FK_Events_FormsOfWorks_FormOfWorkFKId",
  205. column: x => x.FormOfWorkFKId,
  206. principalTable: "FormsOfWorks",
  207. principalColumn: "Id",
  208. onDelete: ReferentialAction.Cascade);
  209. });
  210. migrationBuilder.CreateTable(
  211. name: "MethodicaCommissions",
  212. columns: table => new
  213. {
  214. Id = table.Column<Guid>(type: "uuid", nullable: false),
  215. Name = table.Column<string>(type: "text", nullable: false),
  216. IdHead = table.Column<Guid>(type: "uuid", nullable: true),
  217. HeadMCId = table.Column<Guid>(type: "uuid", nullable: true)
  218. },
  219. constraints: table =>
  220. {
  221. table.PrimaryKey("PK_MethodicaCommissions", x => x.Id);
  222. table.ForeignKey(
  223. name: "FK_MethodicaCommissions_Employees_HeadMCId",
  224. column: x => x.HeadMCId,
  225. principalTable: "Employees",
  226. principalColumn: "Id");
  227. });
  228. migrationBuilder.InsertData(
  229. table: "FormsOfWorks",
  230. columns: new[] { "Id", "Name" },
  231. values: new object[,]
  232. {
  233. { new Guid("1df0cba6-ff73-40c2-abdf-961a9709eaaa"), "Проведение" },
  234. { new Guid("37287ef1-0f2b-4285-9ac4-9f1488ace769"), "Участие" },
  235. { new Guid("b4e09dae-2674-4e96-925f-d9043b546d23"), "Стажировка" },
  236. { new Guid("c1f8d268-888a-42a3-8cb0-1f4844288f7a"), "Публикация" }
  237. });
  238. migrationBuilder.InsertData(
  239. table: "MethodicaCommissions",
  240. columns: new[] { "Id", "HeadMCId", "IdHead", "Name" },
  241. values: new object[,]
  242. {
  243. { new Guid("12da9f6a-76f1-4fc0-8fd9-83e87339d72d"), null, null, "Информатика и вычислительная техника" },
  244. { new Guid("5170e2a5-c6a2-46d4-9b9f-c320a3a38489"), null, null, "Инструментальных дисциплин" },
  245. { new Guid("55d62715-6c8c-4edc-b24a-f40bc74c921b"), null, null, "Математических и естественно - научных дисциплин" },
  246. { new Guid("75a83ea4-1462-4509-a656-551d97c3b2ef"), null, null, "Специальности Преподавание в начальных классах" },
  247. { new Guid("785180c4-76d2-4198-9097-1f7468fb33fa"), null, null, "Экономика и управление, логистика" },
  248. { new Guid("7db12177-6b42-4e46-aaf3-7c0cfd898bf4"), null, null, "Общественных и правовых дисциплин" },
  249. { new Guid("89f72d9d-2c0f-4f6d-b260-1b8c5ad22562"), null, null, "Дисциплин физической культуры и БЖД" },
  250. { new Guid("8e9ba4b0-5b6e-4afe-bc52-1ff89478fffd"), null, null, "Музыкальных дисциплин" },
  251. { new Guid("a3da2342-8d6d-4d41-b93b-3a129a0df358"), null, null, "Специальности Дошкольное образование" },
  252. { new Guid("ab1ace23-f7cd-4b5c-b3ca-6d7569c8f1f5"), null, null, "Специальностей Товароведение, Коммерция" },
  253. { new Guid("ad5ecee4-1b03-4c38-826f-9c48264f8964"), null, null, "Иностранного языка" },
  254. { new Guid("c09cd729-72fe-4fb2-bdbe-ba74605f3e1a"), null, null, "Специальностей Банковское дело, ДОУ" },
  255. { new Guid("de91711c-58d4-4a6c-be28-361418218d11"), null, null, "Гуманитарных дисциплин" }
  256. });
  257. migrationBuilder.CreateIndex(
  258. name: "IX_AspNetRoleClaims_RoleId",
  259. table: "AspNetRoleClaims",
  260. column: "RoleId");
  261. migrationBuilder.CreateIndex(
  262. name: "RoleNameIndex",
  263. table: "AspNetRoles",
  264. column: "NormalizedName",
  265. unique: true);
  266. migrationBuilder.CreateIndex(
  267. name: "IX_AspNetUserClaims_UserId",
  268. table: "AspNetUserClaims",
  269. column: "UserId");
  270. migrationBuilder.CreateIndex(
  271. name: "IX_AspNetUserLogins_UserId",
  272. table: "AspNetUserLogins",
  273. column: "UserId");
  274. migrationBuilder.CreateIndex(
  275. name: "IX_AspNetUserRoles_RoleId",
  276. table: "AspNetUserRoles",
  277. column: "RoleId");
  278. migrationBuilder.CreateIndex(
  279. name: "EmailIndex",
  280. table: "AspNetUsers",
  281. column: "NormalizedEmail");
  282. migrationBuilder.CreateIndex(
  283. name: "UserNameIndex",
  284. table: "AspNetUsers",
  285. column: "NormalizedUserName",
  286. unique: true);
  287. migrationBuilder.CreateIndex(
  288. name: "IX_Employees_UserId",
  289. table: "Employees",
  290. column: "UserId",
  291. unique: true);
  292. migrationBuilder.CreateIndex(
  293. name: "IX_Events_EmployeeId",
  294. table: "Events",
  295. column: "EmployeeId");
  296. migrationBuilder.CreateIndex(
  297. name: "IX_Events_FormOfWorkFKId",
  298. table: "Events",
  299. column: "FormOfWorkFKId");
  300. migrationBuilder.CreateIndex(
  301. name: "IX_MethodicaCommissions_HeadMCId",
  302. table: "MethodicaCommissions",
  303. column: "HeadMCId");
  304. }
  305. /// <inheritdoc />
  306. protected override void Down(MigrationBuilder migrationBuilder)
  307. {
  308. migrationBuilder.DropTable(
  309. name: "AspNetRoleClaims");
  310. migrationBuilder.DropTable(
  311. name: "AspNetUserClaims");
  312. migrationBuilder.DropTable(
  313. name: "AspNetUserLogins");
  314. migrationBuilder.DropTable(
  315. name: "AspNetUserRoles");
  316. migrationBuilder.DropTable(
  317. name: "AspNetUserTokens");
  318. migrationBuilder.DropTable(
  319. name: "Events");
  320. migrationBuilder.DropTable(
  321. name: "MethodicaCommissions");
  322. migrationBuilder.DropTable(
  323. name: "AspNetRoles");
  324. migrationBuilder.DropTable(
  325. name: "FormsOfWorks");
  326. migrationBuilder.DropTable(
  327. name: "Employees");
  328. migrationBuilder.DropTable(
  329. name: "AspNetUsers");
  330. }
  331. }
  332. }