20241030125620_altrCompanyTbl.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace MTWorkHR.Infrastructure.Migrations
  4. {
  5. /// <inheritdoc />
  6. public partial class altrCompanyTbl : Migration
  7. {
  8. /// <inheritdoc />
  9. protected override void Up(MigrationBuilder migrationBuilder)
  10. {
  11. migrationBuilder.AlterColumn<string>(
  12. name: "PhoneNumber",
  13. table: "Companies",
  14. type: "nvarchar(max)",
  15. nullable: false,
  16. oldClrType: typeof(int),
  17. oldType: "int");
  18. migrationBuilder.AlterColumn<string>(
  19. name: "Email",
  20. table: "Companies",
  21. type: "nvarchar(max)",
  22. nullable: false,
  23. oldClrType: typeof(int),
  24. oldType: "int");
  25. migrationBuilder.AlterColumn<string>(
  26. name: "Address",
  27. table: "Companies",
  28. type: "nvarchar(max)",
  29. nullable: false,
  30. oldClrType: typeof(int),
  31. oldType: "int");
  32. migrationBuilder.AddColumn<long>(
  33. name: "CityId",
  34. table: "Companies",
  35. type: "bigint",
  36. nullable: true);
  37. migrationBuilder.AddColumn<long>(
  38. name: "CountryId",
  39. table: "Companies",
  40. type: "bigint",
  41. nullable: true);
  42. migrationBuilder.CreateIndex(
  43. name: "IX_Companies_CityId",
  44. table: "Companies",
  45. column: "CityId");
  46. migrationBuilder.CreateIndex(
  47. name: "IX_Companies_CountryId",
  48. table: "Companies",
  49. column: "CountryId");
  50. migrationBuilder.AddForeignKey(
  51. name: "FK_Companies_Cities_CityId",
  52. table: "Companies",
  53. column: "CityId",
  54. principalTable: "Cities",
  55. principalColumn: "Id");
  56. migrationBuilder.AddForeignKey(
  57. name: "FK_Companies_CountryLookups_CountryId",
  58. table: "Companies",
  59. column: "CountryId",
  60. principalTable: "CountryLookups",
  61. principalColumn: "Id");
  62. }
  63. /// <inheritdoc />
  64. protected override void Down(MigrationBuilder migrationBuilder)
  65. {
  66. migrationBuilder.DropForeignKey(
  67. name: "FK_Companies_Cities_CityId",
  68. table: "Companies");
  69. migrationBuilder.DropForeignKey(
  70. name: "FK_Companies_CountryLookups_CountryId",
  71. table: "Companies");
  72. migrationBuilder.DropIndex(
  73. name: "IX_Companies_CityId",
  74. table: "Companies");
  75. migrationBuilder.DropIndex(
  76. name: "IX_Companies_CountryId",
  77. table: "Companies");
  78. migrationBuilder.DropColumn(
  79. name: "CityId",
  80. table: "Companies");
  81. migrationBuilder.DropColumn(
  82. name: "CountryId",
  83. table: "Companies");
  84. migrationBuilder.AlterColumn<int>(
  85. name: "PhoneNumber",
  86. table: "Companies",
  87. type: "int",
  88. nullable: false,
  89. oldClrType: typeof(string),
  90. oldType: "nvarchar(max)");
  91. migrationBuilder.AlterColumn<int>(
  92. name: "Email",
  93. table: "Companies",
  94. type: "int",
  95. nullable: false,
  96. oldClrType: typeof(string),
  97. oldType: "nvarchar(max)");
  98. migrationBuilder.AlterColumn<int>(
  99. name: "Address",
  100. table: "Companies",
  101. type: "int",
  102. nullable: false,
  103. oldClrType: typeof(string),
  104. oldType: "nvarchar(max)");
  105. }
  106. }
  107. }