20240516101716_altrAttach.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
  4. namespace MTWorkHR.Infrastructure.Migrations
  5. {
  6. /// <inheritdoc />
  7. public partial class altrAttach : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.DropForeignKey(
  13. name: "FK_UserTaskAttachments_AttachmentTypes_AttachmentTypeId",
  14. table: "UserTaskAttachments");
  15. migrationBuilder.AlterColumn<string>(
  16. name: "OriginalName",
  17. table: "UserTaskAttachments",
  18. type: "nvarchar(250)",
  19. maxLength: 250,
  20. nullable: true,
  21. oldClrType: typeof(string),
  22. oldType: "nvarchar(250)",
  23. oldMaxLength: 250);
  24. migrationBuilder.AlterColumn<long>(
  25. name: "AttachmentTypeId",
  26. table: "UserTaskAttachments",
  27. type: "bigint",
  28. nullable: true,
  29. oldClrType: typeof(long),
  30. oldType: "bigint");
  31. migrationBuilder.InsertData(
  32. table: "AttachmentTypes",
  33. columns: new[] { "Id", "IsRequired", "NameAr", "NameEn" },
  34. values: new object[,]
  35. {
  36. { 3L, false, "شهادة التعليم", "Education Certification" },
  37. { 4L, false, "شهادة الخبرة", "Experience Certification" },
  38. { 5L, false, "شهادة الاحتراف", "Professional Certification" }
  39. });
  40. migrationBuilder.AddForeignKey(
  41. name: "FK_UserTaskAttachments_AttachmentTypes_AttachmentTypeId",
  42. table: "UserTaskAttachments",
  43. column: "AttachmentTypeId",
  44. principalTable: "AttachmentTypes",
  45. principalColumn: "Id");
  46. }
  47. /// <inheritdoc />
  48. protected override void Down(MigrationBuilder migrationBuilder)
  49. {
  50. migrationBuilder.DropForeignKey(
  51. name: "FK_UserTaskAttachments_AttachmentTypes_AttachmentTypeId",
  52. table: "UserTaskAttachments");
  53. migrationBuilder.DeleteData(
  54. table: "AttachmentTypes",
  55. keyColumn: "Id",
  56. keyValue: 3L);
  57. migrationBuilder.DeleteData(
  58. table: "AttachmentTypes",
  59. keyColumn: "Id",
  60. keyValue: 4L);
  61. migrationBuilder.DeleteData(
  62. table: "AttachmentTypes",
  63. keyColumn: "Id",
  64. keyValue: 5L);
  65. migrationBuilder.AlterColumn<string>(
  66. name: "OriginalName",
  67. table: "UserTaskAttachments",
  68. type: "nvarchar(250)",
  69. maxLength: 250,
  70. nullable: false,
  71. defaultValue: "",
  72. oldClrType: typeof(string),
  73. oldType: "nvarchar(250)",
  74. oldMaxLength: 250,
  75. oldNullable: true);
  76. migrationBuilder.AlterColumn<long>(
  77. name: "AttachmentTypeId",
  78. table: "UserTaskAttachments",
  79. type: "bigint",
  80. nullable: false,
  81. defaultValue: 0L,
  82. oldClrType: typeof(long),
  83. oldType: "bigint",
  84. oldNullable: true);
  85. migrationBuilder.AddForeignKey(
  86. name: "FK_UserTaskAttachments_AttachmentTypes_AttachmentTypeId",
  87. table: "UserTaskAttachments",
  88. column: "AttachmentTypeId",
  89. principalTable: "AttachmentTypes",
  90. principalColumn: "Id",
  91. onDelete: ReferentialAction.Cascade);
  92. }
  93. }
  94. }