20240318090642_orderReq.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 orderReq : Migration
  9. {
  10. /// <inheritdoc />
  11. protected override void Up(MigrationBuilder migrationBuilder)
  12. {
  13. migrationBuilder.CreateTable(
  14. name: "OrderTypes",
  15. columns: table => new
  16. {
  17. Id = table.Column<long>(type: "bigint", nullable: false)
  18. .Annotation("SqlServer:Identity", "1, 1"),
  19. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  20. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  21. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  22. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  23. NameAr = table.Column<string>(type: "nvarchar(max)", nullable: false),
  24. NameEn = table.Column<string>(type: "nvarchar(max)", nullable: false),
  25. DefaultDays = table.Column<int>(type: "int", nullable: false)
  26. },
  27. constraints: table =>
  28. {
  29. table.PrimaryKey("PK_OrderTypes", x => x.Id);
  30. });
  31. migrationBuilder.CreateTable(
  32. name: "OrderAllocations",
  33. columns: table => new
  34. {
  35. Id = table.Column<long>(type: "bigint", nullable: false)
  36. .Annotation("SqlServer:Identity", "1, 1"),
  37. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  38. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  39. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  40. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  41. NumberOfDays = table.Column<int>(type: "int", nullable: false),
  42. OrderTypeId = table.Column<long>(type: "bigint", nullable: false),
  43. Period = table.Column<int>(type: "int", nullable: false),
  44. EmployeeId = table.Column<string>(type: "nvarchar(max)", nullable: false)
  45. },
  46. constraints: table =>
  47. {
  48. table.PrimaryKey("PK_OrderAllocations", x => x.Id);
  49. table.ForeignKey(
  50. name: "FK_OrderAllocations_OrderTypes_OrderTypeId",
  51. column: x => x.OrderTypeId,
  52. principalTable: "OrderTypes",
  53. principalColumn: "Id",
  54. onDelete: ReferentialAction.Cascade);
  55. });
  56. migrationBuilder.CreateTable(
  57. name: "OrderRequests",
  58. columns: table => new
  59. {
  60. Id = table.Column<long>(type: "bigint", nullable: false)
  61. .Annotation("SqlServer:Identity", "1, 1"),
  62. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  63. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  64. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  65. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  66. IsDeleted = table.Column<bool>(type: "bit", nullable: false),
  67. DeleteUserId = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  68. StartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  69. EndDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  70. OrderTypeId = table.Column<long>(type: "bigint", nullable: false),
  71. DateRequested = table.Column<DateTime>(type: "datetime2", nullable: false),
  72. RequestComments = table.Column<string>(type: "nvarchar(max)", nullable: true),
  73. DateActioned = table.Column<DateTime>(type: "datetime2", nullable: true),
  74. IsApproved = table.Column<bool>(type: "bit", nullable: true),
  75. IsCancelled = table.Column<bool>(type: "bit", nullable: false),
  76. RequestingEmployeeId = table.Column<string>(type: "nvarchar(max)", nullable: false)
  77. },
  78. constraints: table =>
  79. {
  80. table.PrimaryKey("PK_OrderRequests", x => x.Id);
  81. table.ForeignKey(
  82. name: "FK_OrderRequests_OrderTypes_OrderTypeId",
  83. column: x => x.OrderTypeId,
  84. principalTable: "OrderTypes",
  85. principalColumn: "Id",
  86. onDelete: ReferentialAction.Cascade);
  87. });
  88. migrationBuilder.InsertData(
  89. table: "OrderTypes",
  90. columns: new[] { "Id", "CreateDate", "CreateUser", "DefaultDays", "NameAr", "NameEn", "UpdateDate", "UpdateUser" },
  91. values: new object[,]
  92. {
  93. { 1L, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, 2, "إذن", "Leave", null, null },
  94. { 2L, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, 15, "أجازة مرضية", "Sick Leave", null, null },
  95. { 3L, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, 20, "وقت إضافي", "Overtime", null, null },
  96. { 4L, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, 0, "رحلة عمل", "Business trip", null, null },
  97. { 5L, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, 0, "دورة تدريبية", "Course", null, null }
  98. });
  99. migrationBuilder.CreateIndex(
  100. name: "IX_OrderAllocations_OrderTypeId",
  101. table: "OrderAllocations",
  102. column: "OrderTypeId");
  103. migrationBuilder.CreateIndex(
  104. name: "IX_OrderRequests_OrderTypeId",
  105. table: "OrderRequests",
  106. column: "OrderTypeId");
  107. }
  108. /// <inheritdoc />
  109. protected override void Down(MigrationBuilder migrationBuilder)
  110. {
  111. migrationBuilder.DropTable(
  112. name: "OrderAllocations");
  113. migrationBuilder.DropTable(
  114. name: "OrderRequests");
  115. migrationBuilder.DropTable(
  116. name: "OrderTypes");
  117. }
  118. }
  119. }