20241029101807_altrUserCompany_addNationality.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
  5. namespace MTWorkHR.Infrastructure.Migrations
  6. {
  7. /// <inheritdoc />
  8. public partial class altrUserCompany_addNationality : Migration
  9. {
  10. /// <inheritdoc />
  11. protected override void Up(MigrationBuilder migrationBuilder)
  12. {
  13. migrationBuilder.AddColumn<int>(
  14. name: "ContractStatusId",
  15. table: "Contracts",
  16. type: "int",
  17. nullable: false,
  18. defaultValue: 0);
  19. migrationBuilder.AddColumn<int>(
  20. name: "ContractorTaxResidencyId",
  21. table: "Contracts",
  22. type: "int",
  23. nullable: false,
  24. defaultValue: 0);
  25. migrationBuilder.AddColumn<int>(
  26. name: "Address",
  27. table: "Companies",
  28. type: "int",
  29. nullable: false,
  30. defaultValue: 0);
  31. migrationBuilder.AddColumn<int>(
  32. name: "Email",
  33. table: "Companies",
  34. type: "int",
  35. nullable: false,
  36. defaultValue: 0);
  37. migrationBuilder.AddColumn<int>(
  38. name: "PhoneNumber",
  39. table: "Companies",
  40. type: "int",
  41. nullable: false,
  42. defaultValue: 0);
  43. migrationBuilder.AddColumn<string>(
  44. name: "CompanyRepresentativeTitle",
  45. table: "AspNetUsers",
  46. type: "nvarchar(max)",
  47. nullable: true);
  48. migrationBuilder.AddColumn<long>(
  49. name: "NationalityId",
  50. table: "AspNetUsers",
  51. type: "bigint",
  52. nullable: true);
  53. migrationBuilder.AddColumn<DateTime>(
  54. name: "PassportExpiryDate",
  55. table: "AspNetUsers",
  56. type: "datetime2",
  57. nullable: true);
  58. migrationBuilder.CreateTable(
  59. name: "Nationalities",
  60. columns: table => new
  61. {
  62. Id = table.Column<long>(type: "bigint", nullable: false)
  63. .Annotation("SqlServer:Identity", "1, 1"),
  64. NameAr = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  65. NameEn = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  66. CountryCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
  67. CountryId = table.Column<string>(type: "nvarchar(max)", nullable: true)
  68. },
  69. constraints: table =>
  70. {
  71. table.PrimaryKey("PK_Nationalities", x => x.Id);
  72. });
  73. migrationBuilder.UpdateData(
  74. table: "AspNetUsers",
  75. keyColumn: "Id",
  76. keyValue: "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
  77. columns: new[] { "CompanyRepresentativeTitle", "NationalityId", "PassportExpiryDate" },
  78. values: new object[] { null, null, null });
  79. migrationBuilder.UpdateData(
  80. table: "AspNetUsers",
  81. keyColumn: "Id",
  82. keyValue: "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",
  83. columns: new[] { "CompanyRepresentativeTitle", "NationalityId", "PassportExpiryDate" },
  84. values: new object[] { null, null, null });
  85. migrationBuilder.InsertData(
  86. table: "Nationalities",
  87. columns: new[] { "Id", "CountryCode", "CountryId", "NameAr", "NameEn" },
  88. values: new object[,]
  89. {
  90. { 1L, "AF", null, "أفغاني", "Afghan" },
  91. { 2L, "AL", null, "ألباني", "Albanian" },
  92. { 3L, "DZ", null, "جزائري", "Algerian" },
  93. { 4L, "AS", null, "أمريكي ساموي", "American Samoan" },
  94. { 5L, "US", null, "أمريكي", "American" },
  95. { 6L, "AD", null, "أندوري", "Andorran" },
  96. { 7L, "AO", null, "أنغولي", "Angolan" },
  97. { 8L, "AI", null, "أنغويلي", "Anguillian" },
  98. { 9L, "AG", null, "أنتيغي", "Antiguan" },
  99. { 10L, "AR", null, "أرجنتيني", "Argentinian" },
  100. { 11L, "AM", null, "أرميني", "Armenian" },
  101. { 12L, "AW", null, "أروبي", "Aruban" },
  102. { 13L, "AU", null, "أسترالي", "Australian" },
  103. { 14L, "AT", null, "نمساوي", "Austrian" },
  104. { 15L, "AZ", null, "أذربيجاني", "Azerbaijani" },
  105. { 16L, "BS", null, "باهامي", "Bahamian" },
  106. { 17L, "BH", null, "بحريني", "Bahraini" },
  107. { 18L, "BD", null, "بنغلاديشي", "Bangladeshi" },
  108. { 19L, "BB", null, "باربادوسي", "Barbadian" },
  109. { 20L, "BY", null, "بيلاروسي", "Belarusian" },
  110. { 21L, "BE", null, "بلجيكي", "Belgian" },
  111. { 22L, "BZ", null, "بليزي", "Belizean" },
  112. { 23L, "BJ", null, "بنيني", "Beninese" },
  113. { 24L, "BT", null, "بوتاني", "Bhutanese" },
  114. { 25L, "BO", null, "بوليفي", "Bolivian" },
  115. { 26L, "BA", null, "بوسني", "Bosnian" },
  116. { 27L, "BR", null, "برازيلي", "Brazilian" },
  117. { 28L, "GB", null, "بريطاني", "British" },
  118. { 29L, "BN", null, "بروني", "Bruneian" },
  119. { 30L, "BG", null, "بلغاري", "Bulgarian" },
  120. { 31L, "BF", null, "بوركيني", "Burkinabe" },
  121. { 32L, "MM", null, "بورمي", "Burmese" },
  122. { 33L, "BI", null, "بوروندي", "Burundian" },
  123. { 34L, "KH", null, "كمبودي", "Cambodian" },
  124. { 35L, "CM", null, "كاميروني", "Cameroonian" },
  125. { 36L, "CA", null, "كندي", "Canadian" },
  126. { 37L, "CV", null, "الرأس الأخضر", "Cape Verdean" },
  127. { 38L, "CF", null, "أفريقي أوسط", "Central African" },
  128. { 39L, "TD", null, "تشادي", "Chadian" },
  129. { 40L, "CL", null, "تشيلي", "Chilean" },
  130. { 41L, "CN", null, "صيني", "Chinese" },
  131. { 42L, "CO", null, "كولومبي", "Colombian" },
  132. { 43L, "KM", null, "قُمُري", "Comorian" },
  133. { 44L, "CG", null, "كونغولي", "Congolese" },
  134. { 45L, "CR", null, "كوستاريكي", "Costa Rican" },
  135. { 46L, "HR", null, "كرواتي", "Croatian" },
  136. { 47L, "CU", null, "كوبي", "Cuban" },
  137. { 48L, "CY", null, "قبرصي", "Cypriot" },
  138. { 49L, "CZ", null, "تشيكي", "Czech" },
  139. { 50L, "DK", null, "دنماركي", "Danish" },
  140. { 51L, "DJ", null, "جيبوتي", "Djiboutian" },
  141. { 52L, "DO", null, "دومينيكاني", "Dominican" },
  142. { 53L, "NL", null, "هولندي", "Dutch" },
  143. { 54L, "EC", null, "إكوادوري", "Ecuadorean" },
  144. { 55L, "EG", null, "مصري", "Egyptian" },
  145. { 56L, "AE", null, "إماراتي", "Emirati" },
  146. { 57L, "GQ", null, "غيني استوائي", "Equatorial Guinean" },
  147. { 58L, "ER", null, "إريتيري", "Eritrean" },
  148. { 59L, "EE", null, "إستوني", "Estonian" },
  149. { 60L, "ET", null, "أثيوبي", "Ethiopian" },
  150. { 61L, "FJ", null, "فيجي", "Fijian" },
  151. { 62L, "FI", null, "فنلندي", "Finnish" },
  152. { 63L, "FR", null, "فرنسي", "French" },
  153. { 64L, "GA", null, "غابوني", "Gabonese" },
  154. { 65L, "GM", null, "غامبي", "Gambian" },
  155. { 66L, "GE", null, "جورجي", "Georgian" },
  156. { 67L, "DE", null, "ألماني", "German" },
  157. { 68L, "GH", null, "غاني", "Ghanaian" },
  158. { 69L, "GI", null, "جبل طارق", "Gibraltarian" },
  159. { 70L, "GR", null, "يوناني", "Greek" },
  160. { 71L, "GL", null, "جرينلندي", "Greenlandic" },
  161. { 72L, "GD", null, "غرينادي", "Grenadian" },
  162. { 73L, "GU", null, "غوامي", "Guamanian" },
  163. { 74L, "GT", null, "غواتيمالي", "Guatemalan" },
  164. { 75L, "GN", null, "غيني", "Guinean" },
  165. { 76L, "GW", null, "غيني", "Guinean" },
  166. { 77L, "GY", null, "غياني", "Guyanese" },
  167. { 78L, "HT", null, "هايتي", "Haitian" },
  168. { 79L, "HN", null, "هندوراسي", "Honduran" },
  169. { 80L, "HK", null, "هونغ كونغي", "Hong Konger" },
  170. { 81L, "HU", null, "مجري", "Hungarian" },
  171. { 82L, "IS", null, "آيسلندي", "Icelander" },
  172. { 83L, "IN", null, "هندي", "Indian" },
  173. { 84L, "ID", null, "إندونيسي", "Indonesian" },
  174. { 85L, "IR", null, "إيراني", "Iranian" },
  175. { 86L, "IQ", null, "عراقي", "Iraqi" },
  176. { 87L, "IE", null, "إيرلندي", "Irish" },
  177. { 89L, "IT", null, "إيطالي", "Italian" },
  178. { 90L, "JM", null, "جامايكي", "Jamaican" },
  179. { 91L, "JP", null, "ياباني", "Japanese" },
  180. { 92L, "JE", null, "جيرسي", "Jersey" },
  181. { 93L, "JO", null, "أردني", "Jordanian" },
  182. { 94L, "KZ", null, "كازاخي", "Kazakh" },
  183. { 95L, "KE", null, "كيني", "Kenyan" },
  184. { 96L, "KI", null, "كيريباتي", "Kiribati" },
  185. { 97L, "KP", null, "كوري شمالي", "North Korean" },
  186. { 98L, "KR", null, "كوري جنوبي", "South Korean" },
  187. { 99L, "KW", null, "كويتي", "Kuwaiti" },
  188. { 100L, "KG", null, "قرغيزستاني", "Kyrgyzstani" },
  189. { 101L, "LA", null, "لاوي", "Lao" },
  190. { 102L, "LV", null, "لاتفي", "Latvian" },
  191. { 103L, "LB", null, "لبناني", "Lebanese" },
  192. { 104L, "LS", null, "ليسوتو", "Lesotho" },
  193. { 105L, "LR", null, "ليبيريي", "Liberian" },
  194. { 106L, "LY", null, "ليبي", "Libyan" },
  195. { 107L, "LI", null, "ليختنشتايني", "Liechtensteiner" },
  196. { 108L, "LT", null, "ليتواني", "Lithuanian" },
  197. { 109L, "LU", null, "لوكسمبورغي", "Luxembourgish" },
  198. { 110L, "MG", null, "ملغاشي", "Malagasy" },
  199. { 111L, "MW", null, "ملووي", "Malawian" },
  200. { 112L, "MY", null, "ماليزيا", "Malaysian" },
  201. { 113L, "MV", null, "مالديفي", "Maldivian" },
  202. { 114L, "ML", null, "مالي", "Malian" },
  203. { 115L, "MT", null, "مالطي", "Maltese" },
  204. { 116L, "MH", null, "مارشالي", "Marshallese" },
  205. { 117L, "MR", null, "موريتاني", "Mauritanian" },
  206. { 118L, "MU", null, "موريشيوسي", "Mauritian" },
  207. { 119L, "MX", null, "مكسيكي", "Mexican" },
  208. { 120L, "FM", null, "ماكروني", "Micronesian" },
  209. { 121L, "MD", null, "مولدوفي", "Moldovan" },
  210. { 122L, "MC", null, "موناكي", "Monacan" },
  211. { 123L, "MN", null, "منغولي", "Mongolian" },
  212. { 124L, "ME", null, "مونتينيغري", "Montenegrin" },
  213. { 125L, "MA", null, "مغربي", "Moroccan" },
  214. { 126L, "MZ", null, "موزمبيقي", "Mozambican" },
  215. { 127L, "NA", null, "ناميبي", "Namibian" },
  216. { 128L, "NR", null, "نيواروي", "Nauruan" },
  217. { 129L, "NP", null, "نيبالي", "Nepali" },
  218. { 130L, "NL", null, "هولندي", "Dutch" },
  219. { 131L, "NZ", null, "نيوزيلندي", "New Zealander" },
  220. { 132L, "NI", null, "نيكاراغوي", "Nicaraguan" },
  221. { 133L, "NE", null, "نيجيري", "Nigerien" },
  222. { 134L, "NG", null, "نيجيري", "Nigerian" },
  223. { 135L, "MK", null, "مقدوني شمالي", "North Macedonian" },
  224. { 136L, "NO", null, "نرويجي", "Norwegian" },
  225. { 137L, "OM", null, "عماني", "Omani" },
  226. { 138L, "PK", null, "باكستاني", "Pakistani" },
  227. { 139L, "PW", null, "بالاوي", "Palauan" },
  228. { 140L, "PA", null, "بنمي", "Panamanian" },
  229. { 141L, "PG", null, "بابوا غينيا الجديدة", "Papua New Guinean" },
  230. { 142L, "PY", null, "باراغواني", "Paraguayan" },
  231. { 143L, "PE", null, "بيروفي", "Peruvian" },
  232. { 144L, "PH", null, "فلبيني", "Filipino" },
  233. { 145L, "PL", null, "بولندي", "Polish" },
  234. { 146L, "PT", null, "برتغالي", "Portuguese" },
  235. { 147L, "QA", null, "قطري", "Qatari" },
  236. { 148L, "RE", null, "لا ريونيون", "Réunionese" },
  237. { 149L, "RO", null, "روماني", "Romanian" },
  238. { 150L, "RU", null, "روسي", "Russian" },
  239. { 151L, "RW", null, "رواندي", "Rwandan" },
  240. { 152L, "BL", null, "سانت بارتيليمي", "Saint Barthélemy" },
  241. { 153L, "SH", null, "سانت هيلاني", "Saint Helenian" },
  242. { 154L, "KN", null, "سانت كيتس ونيفيس", "Saint Kitts and Nevis" },
  243. { 155L, "LC", null, "سانت لوسيان", "Saint Lucian" },
  244. { 156L, "MF", null, "سانت مارتن", "Saint Martin" },
  245. { 157L, "SX", null, "سانت مارتن", "Sint Maarten" },
  246. { 158L, "WS", null, "سماوي", "Samoan" },
  247. { 159L, "SM", null, "سانماريني", "Sammarinese" },
  248. { 160L, "ST", null, "ساو توماني", "Sao Tomean" },
  249. { 161L, "SA", null, "سعودي", "Saudi" },
  250. { 162L, "SN", null, "سنغالي", "Senegalese" },
  251. { 163L, "RS", null, "صربي", "Serbian" },
  252. { 164L, "SC", null, "سيشلي", "Seychellois" },
  253. { 165L, "SL", null, "سيراليوني", "Sierra Leonean" },
  254. { 166L, "SG", null, "سنغافوري", "Singaporean" },
  255. { 167L, "SK", null, "سلوفاكي", "Slovak" },
  256. { 168L, "SI", null, "سلوفيني", "Slovenian" },
  257. { 169L, "SB", null, "سولوموني", "Solomon Islander" },
  258. { 170L, "SO", null, "صومالي", "Somali" },
  259. { 171L, "ZA", null, "جنوب أفريقي", "South African" },
  260. { 172L, "SS", null, "جنوب سوداني", "South Sudanese" },
  261. { 173L, "ES", null, "إسباني", "Spanish" },
  262. { 174L, "LK", null, "سريلانكي", "Sri Lankan" },
  263. { 175L, "SD", null, "سوداني", "Sudanese" },
  264. { 176L, "SR", null, "سورينامي", "Surinamese" },
  265. { 177L, "SZ", null, "سواتي", "Swazi" },
  266. { 178L, "SE", null, "سويدي", "Swedish" },
  267. { 179L, "CH", null, "سويسري", "Swiss" },
  268. { 180L, "SY", null, "سوري", "Syrian" },
  269. { 181L, "TW", null, "تايواني", "Taiwanese" },
  270. { 182L, "TJ", null, "طاجيكي", "Tajik" },
  271. { 183L, "TZ", null, "تنزاني", "Tanzanian" },
  272. { 184L, "TH", null, "تايلندي", "Thai" },
  273. { 185L, "TL", null, "تيموري", "Timorese" },
  274. { 186L, "TG", null, "توغولي", "Togolese" },
  275. { 187L, "TK", null, "توكلاوي", "Tokelauan" },
  276. { 188L, "TO", null, "تونغي", "Tongan" },
  277. { 189L, "TT", null, "ترينيدادي", "Trinidadian" },
  278. { 190L, "TN", null, "تونسي", "Tunisian" },
  279. { 191L, "TR", null, "تركي", "Turkish" },
  280. { 192L, "TM", null, "تركماني", "Turkmen" },
  281. { 193L, "TC", null, "تركي وكايكوسي", "Turks and Caicos Islander" },
  282. { 194L, "TV", null, "توفالي", "Tuvaluan" },
  283. { 195L, "UG", null, "أوغندي", "Ugandan" },
  284. { 196L, "UA", null, "أوكراني", "Ukrainian" },
  285. { 197L, "AE", null, "إماراتي", "Emirati" },
  286. { 198L, "GB", null, "بريطاني", "British" },
  287. { 199L, "US", null, "أمريكي", "American" },
  288. { 200L, "UY", null, "أوروغواي", "Uruguayan" },
  289. { 201L, "UZ", null, "أوزبكي", "Uzbek" },
  290. { 202L, "VU", null, "فانواتي", "Vanuatuan" },
  291. { 203L, "VE", null, "فنزويلي", "Venezuelan" },
  292. { 204L, "VN", null, "فيتنامي", "Vietnamese" },
  293. { 205L, "WF", null, "واليس وفوتونا", "Wallis and Futuna" },
  294. { 206L, "YE", null, "يمني", "Yemeni" },
  295. { 207L, "ZM", null, "زامبي", "Zambian" },
  296. { 208L, "ZW", null, "زيمبابوي", "Zimbabwean" }
  297. });
  298. migrationBuilder.CreateIndex(
  299. name: "IX_AspNetUsers_NationalityId",
  300. table: "AspNetUsers",
  301. column: "NationalityId");
  302. migrationBuilder.AddForeignKey(
  303. name: "FK_AspNetUsers_Nationalities_NationalityId",
  304. table: "AspNetUsers",
  305. column: "NationalityId",
  306. principalTable: "Nationalities",
  307. principalColumn: "Id");
  308. var sqlStm = @"update Nationalities set CountryId = (select top 1 id from CountryLookups where UPPER(CountryCode)=UPPER(code))";
  309. migrationBuilder.Sql(sqlStm);
  310. }
  311. /// <inheritdoc />
  312. protected override void Down(MigrationBuilder migrationBuilder)
  313. {
  314. migrationBuilder.DropForeignKey(
  315. name: "FK_AspNetUsers_Nationalities_NationalityId",
  316. table: "AspNetUsers");
  317. migrationBuilder.DropTable(
  318. name: "Nationalities");
  319. migrationBuilder.DropIndex(
  320. name: "IX_AspNetUsers_NationalityId",
  321. table: "AspNetUsers");
  322. migrationBuilder.DropColumn(
  323. name: "ContractStatusId",
  324. table: "Contracts");
  325. migrationBuilder.DropColumn(
  326. name: "ContractorTaxResidencyId",
  327. table: "Contracts");
  328. migrationBuilder.DropColumn(
  329. name: "Address",
  330. table: "Companies");
  331. migrationBuilder.DropColumn(
  332. name: "Email",
  333. table: "Companies");
  334. migrationBuilder.DropColumn(
  335. name: "PhoneNumber",
  336. table: "Companies");
  337. migrationBuilder.DropColumn(
  338. name: "CompanyRepresentativeTitle",
  339. table: "AspNetUsers");
  340. migrationBuilder.DropColumn(
  341. name: "NationalityId",
  342. table: "AspNetUsers");
  343. migrationBuilder.DropColumn(
  344. name: "PassportExpiryDate",
  345. table: "AspNetUsers");
  346. }
  347. }
  348. }