20210910105657_spDB0910.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. namespace wispro.sp.api.Migrations
  4. {
  5. public partial class spDB0910 : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "StaffGrade",
  11. columns: table => new
  12. {
  13. Id = table.Column<int>(type: "int", nullable: false)
  14. .Annotation("SqlServer:Identity", "1, 1"),
  15. Grade = table.Column<string>(type: "nchar(5)", fixedLength: true, maxLength: 5, nullable: false),
  16. Coefficient = table.Column<double>(type: "float", nullable: false)
  17. },
  18. constraints: table =>
  19. {
  20. table.PrimaryKey("PK_StaffGrade", x => x.Id);
  21. });
  22. migrationBuilder.CreateTable(
  23. name: "Staff",
  24. columns: table => new
  25. {
  26. Id = table.Column<int>(type: "int", nullable: false),
  27. Account = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  28. Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
  29. Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  30. Status = table.Column<string>(type: "nvarchar(25)", maxLength: 25, nullable: false),
  31. isCalPerformsnce = table.Column<bool>(type: "bit", nullable: false),
  32. StaffGradeId = table.Column<int>(type: "int", nullable: false),
  33. Department = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  34. WorkPlace = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  35. EntyDate = table.Column<DateTime>(type: "date", nullable: true),
  36. Memo = table.Column<string>(type: "nvarchar(max)", nullable: true)
  37. },
  38. constraints: table =>
  39. {
  40. table.PrimaryKey("PK_Staff", x => x.Id);
  41. table.ForeignKey(
  42. name: "FK_Staff_StaffGrade",
  43. column: x => x.StaffGradeId,
  44. principalTable: "StaffGrade",
  45. principalColumn: "Id",
  46. onDelete: ReferentialAction.Restrict);
  47. });
  48. migrationBuilder.CreateTable(
  49. name: "VerifyCoefficient",
  50. columns: table => new
  51. {
  52. CheckerId = table.Column<int>(type: "int", nullable: false),
  53. DoPersonId = table.Column<int>(type: "int", nullable: false),
  54. Coefficient = table.Column<double>(type: "float", nullable: false)
  55. },
  56. constraints: table =>
  57. {
  58. table.PrimaryKey("PK_VerifyCoefficient", x => new { x.CheckerId, x.DoPersonId });
  59. table.ForeignKey(
  60. name: "FK_VerifyCoefficient_StaffGrade",
  61. column: x => x.CheckerId,
  62. principalTable: "StaffGrade",
  63. principalColumn: "Id",
  64. onDelete: ReferentialAction.Restrict);
  65. table.ForeignKey(
  66. name: "FK_VerifyCoefficient_StaffGrade1",
  67. column: x => x.DoPersonId,
  68. principalTable: "StaffGrade",
  69. principalColumn: "Id",
  70. onDelete: ReferentialAction.Restrict);
  71. });
  72. migrationBuilder.CreateTable(
  73. name: "Customer",
  74. columns: table => new
  75. {
  76. Id = table.Column<int>(type: "int", nullable: false),
  77. Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  78. ContactMan = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  79. Address = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
  80. Phone = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  81. ResponseManId = table.Column<int>(type: "int", nullable: true)
  82. },
  83. constraints: table =>
  84. {
  85. table.PrimaryKey("PK_Customer", x => x.Id);
  86. table.ForeignKey(
  87. name: "FK_Customer_Staff",
  88. column: x => x.ResponseManId,
  89. principalTable: "Staff",
  90. principalColumn: "Id",
  91. onDelete: ReferentialAction.Restrict);
  92. });
  93. migrationBuilder.CreateTable(
  94. name: "PerformanceItem",
  95. columns: table => new
  96. {
  97. Id = table.Column<int>(type: "int", nullable: false)
  98. .Annotation("SqlServer:Identity", "1, 1"),
  99. Year = table.Column<int>(type: "int", nullable: false),
  100. Month = table.Column<int>(type: "int", nullable: false),
  101. CaseNo = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  102. ApplicationType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  103. BusinessType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  104. AgentFeedbackMemo = table.Column<string>(type: "nvarchar(max)", nullable: true),
  105. DoItem = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  106. CaseStage = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  107. CaseCoefficient = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
  108. DoItemCoefficient = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  109. PreOAStaffId = table.Column<int>(type: "int", nullable: true),
  110. ReviewerId = table.Column<int>(type: "int", nullable: true),
  111. CustomerId = table.Column<int>(type: "int", nullable: true),
  112. ApplicationName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  113. FinishedDate = table.Column<DateTime>(type: "date", nullable: true),
  114. FinalizationDate = table.Column<DateTime>(type: "date", nullable: true),
  115. ReturnDate = table.Column<DateTime>(type: "date", nullable: true),
  116. CaseType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  117. CaseState = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  118. DoItemMemo = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
  119. DoItemState = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  120. CaseName = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
  121. CustomerLimitDate = table.Column<DateTime>(type: "date", nullable: true),
  122. EntrustingDate = table.Column<DateTime>(type: "date", nullable: true),
  123. InternalDate = table.Column<DateTime>(type: "date", nullable: true),
  124. FirstDraftDate = table.Column<DateTime>(type: "date", nullable: true),
  125. OverDueMemo = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
  126. BasePoint = table.Column<decimal>(type: "numeric(18,2)", nullable: true),
  127. status = table.Column<int>(type: "int", nullable: true),
  128. StaffId = table.Column<int>(type: "int", nullable: true)
  129. },
  130. constraints: table =>
  131. {
  132. table.PrimaryKey("PK_PerformanceItem", x => x.Id);
  133. table.ForeignKey(
  134. name: "FK_PerformanceItem_Customer",
  135. column: x => x.CustomerId,
  136. principalTable: "Customer",
  137. principalColumn: "Id",
  138. onDelete: ReferentialAction.Restrict);
  139. table.ForeignKey(
  140. name: "FK_PerformanceItem_Reviewer",
  141. column: x => x.ReviewerId,
  142. principalTable: "Staff",
  143. principalColumn: "Id",
  144. onDelete: ReferentialAction.Restrict);
  145. table.ForeignKey(
  146. name: "FK_PerformanceItem_Staff",
  147. column: x => x.PreOAStaffId,
  148. principalTable: "Staff",
  149. principalColumn: "Id",
  150. onDelete: ReferentialAction.Restrict);
  151. table.ForeignKey(
  152. name: "FK_PerformanceItem_Staff_StaffId",
  153. column: x => x.StaffId,
  154. principalTable: "Staff",
  155. principalColumn: "Id",
  156. onDelete: ReferentialAction.Restrict);
  157. });
  158. migrationBuilder.CreateTable(
  159. name: "ItemStaff",
  160. columns: table => new
  161. {
  162. ItemId = table.Column<int>(type: "int", nullable: false),
  163. DoPersonId = table.Column<int>(type: "int", nullable: false),
  164. PerformancePoint = table.Column<double>(type: "float", nullable: false)
  165. },
  166. constraints: table =>
  167. {
  168. table.PrimaryKey("PK_ItemStaff", x => new { x.ItemId, x.DoPersonId });
  169. table.ForeignKey(
  170. name: "FK_ItemStaff_PerformanceItem",
  171. column: x => x.ItemId,
  172. principalTable: "PerformanceItem",
  173. principalColumn: "Id",
  174. onDelete: ReferentialAction.Restrict);
  175. table.ForeignKey(
  176. name: "FK_ItemStaff_Staff",
  177. column: x => x.DoPersonId,
  178. principalTable: "Staff",
  179. principalColumn: "Id",
  180. onDelete: ReferentialAction.Restrict);
  181. });
  182. migrationBuilder.InsertData(
  183. table: "StaffGrade",
  184. columns: new[] { "Id", "Coefficient", "Grade" },
  185. values: new object[,]
  186. {
  187. { 1, 1.2, "S级" },
  188. { 2, 1.1000000000000001, "A3级" },
  189. { 3, 1.1000000000000001, "A2级" },
  190. { 4, 1.1000000000000001, "A1级" },
  191. { 5, 1.0, "B3级" },
  192. { 6, 1.0, "B2级" },
  193. { 7, 0.90000000000000002, "B1级" },
  194. { 8, 0.90000000000000002, "C3级" },
  195. { 9, 0.69999999999999996, "C2级" },
  196. { 10, 0.69999999999999996, "C1级" },
  197. { 11, 0.59999999999999998, "D3级" },
  198. { 12, 0.59999999999999998, "D2级" },
  199. { 13, 0.5, "D1级" }
  200. });
  201. migrationBuilder.InsertData(
  202. table: "VerifyCoefficient",
  203. columns: new[] { "CheckerId", "DoPersonId", "Coefficient" },
  204. values: new object[,]
  205. {
  206. { 2, 5, 0.20000000000000001 },
  207. { 2, 13, 0.5 },
  208. { 4, 12, 0.40000000000000002 },
  209. { 3, 12, 0.40000000000000002 },
  210. { 2, 12, 0.40000000000000002 },
  211. { 4, 11, 0.40000000000000002 },
  212. { 3, 11, 0.40000000000000002 },
  213. { 2, 11, 0.40000000000000002 },
  214. { 4, 10, 0.29999999999999999 },
  215. { 3, 10, 0.29999999999999999 },
  216. { 2, 10, 0.29999999999999999 },
  217. { 4, 9, 0.29999999999999999 },
  218. { 3, 13, 0.5 },
  219. { 3, 9, 0.29999999999999999 },
  220. { 4, 8, 0.20000000000000001 },
  221. { 3, 8, 0.20000000000000001 },
  222. { 2, 8, 0.20000000000000001 },
  223. { 4, 7, 0.20000000000000001 },
  224. { 3, 7, 0.20000000000000001 },
  225. { 2, 7, 0.20000000000000001 },
  226. { 4, 6, 0.20000000000000001 },
  227. { 3, 6, 0.20000000000000001 },
  228. { 2, 6, 0.20000000000000001 },
  229. { 4, 5, 0.20000000000000001 },
  230. { 3, 5, 0.20000000000000001 },
  231. { 2, 9, 0.29999999999999999 },
  232. { 4, 13, 0.5 }
  233. });
  234. migrationBuilder.CreateIndex(
  235. name: "IX_Customer_ResponseManId",
  236. table: "Customer",
  237. column: "ResponseManId");
  238. migrationBuilder.CreateIndex(
  239. name: "IX_ItemStaff_DoPersonId",
  240. table: "ItemStaff",
  241. column: "DoPersonId");
  242. migrationBuilder.CreateIndex(
  243. name: "IX_PerformanceItem_CustomerId",
  244. table: "PerformanceItem",
  245. column: "CustomerId");
  246. migrationBuilder.CreateIndex(
  247. name: "IX_PerformanceItem_PreOAStaffId",
  248. table: "PerformanceItem",
  249. column: "PreOAStaffId");
  250. migrationBuilder.CreateIndex(
  251. name: "IX_PerformanceItem_ReviewerId",
  252. table: "PerformanceItem",
  253. column: "ReviewerId");
  254. migrationBuilder.CreateIndex(
  255. name: "IX_PerformanceItem_StaffId",
  256. table: "PerformanceItem",
  257. column: "StaffId");
  258. migrationBuilder.CreateIndex(
  259. name: "IX_Staff_StaffGradeId",
  260. table: "Staff",
  261. column: "StaffGradeId");
  262. migrationBuilder.CreateIndex(
  263. name: "IX_VerifyCoefficient_DoPersonId",
  264. table: "VerifyCoefficient",
  265. column: "DoPersonId");
  266. }
  267. protected override void Down(MigrationBuilder migrationBuilder)
  268. {
  269. migrationBuilder.DropTable(
  270. name: "ItemStaff");
  271. migrationBuilder.DropTable(
  272. name: "VerifyCoefficient");
  273. migrationBuilder.DropTable(
  274. name: "PerformanceItem");
  275. migrationBuilder.DropTable(
  276. name: "Customer");
  277. migrationBuilder.DropTable(
  278. name: "Staff");
  279. migrationBuilder.DropTable(
  280. name: "StaffGrade");
  281. }
  282. }
  283. }