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