20210413091839_Init.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. namespace WCS.Service.Migrations
  4. {
  5. public partial class Init : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "WCS_DEVICE",
  11. columns: table => new
  12. {
  13. CODE = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  14. NAME = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  15. TYPE = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
  16. ENABLED = table.Column<bool>(type: "bit", nullable: false),
  17. UPDATEUSER = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  18. UPDATETIME = table.Column<DateTime>(type: "datetime2", nullable: false),
  19. VER = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
  20. },
  21. constraints: table =>
  22. {
  23. table.PrimaryKey("PK_WCS_DEVICE", x => x.CODE);
  24. });
  25. migrationBuilder.CreateTable(
  26. name: "WCS_EXCEPTION",
  27. columns: table => new
  28. {
  29. ID = table.Column<int>(type: "int", nullable: false)
  30. .Annotation("SqlServer:Identity", "1, 1"),
  31. MSG = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
  32. STARTTIME = table.Column<DateTime>(type: "datetime2", nullable: false),
  33. TIMES = table.Column<int>(type: "int", nullable: false),
  34. ENABLED = table.Column<bool>(type: "bit", nullable: false),
  35. UPDATEUSER = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  36. UPDATETIME = table.Column<DateTime>(type: "datetime2", nullable: false),
  37. VER = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
  38. },
  39. constraints: table =>
  40. {
  41. table.PrimaryKey("PK_WCS_EXCEPTION", x => x.ID);
  42. });
  43. migrationBuilder.CreateTable(
  44. name: "WCS_PLC",
  45. columns: table => new
  46. {
  47. ID = table.Column<int>(type: "int", nullable: false)
  48. .Annotation("SqlServer:Identity", "1, 1"),
  49. NAME = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
  50. IP = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
  51. PORT = table.Column<int>(type: "int", nullable: false),
  52. SLOT = table.Column<int>(type: "int", nullable: false),
  53. RACK = table.Column<int>(type: "int", nullable: false),
  54. ENABLED = table.Column<bool>(type: "bit", nullable: false),
  55. UPDATEUSER = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  56. UPDATETIME = table.Column<DateTime>(type: "datetime2", nullable: false),
  57. VER = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
  58. },
  59. constraints: table =>
  60. {
  61. table.PrimaryKey("PK_WCS_PLC", x => x.ID);
  62. });
  63. migrationBuilder.CreateTable(
  64. name: "WCS_DATABLOCK",
  65. columns: table => new
  66. {
  67. ID = table.Column<int>(type: "int", nullable: false)
  68. .Annotation("SqlServer:Identity", "1, 1"),
  69. NAME = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
  70. PLCID = table.Column<int>(type: "int", nullable: true),
  71. NO = table.Column<int>(type: "int", nullable: false),
  72. LENGTH = table.Column<int>(type: "int", nullable: false),
  73. DATALENGTH = table.Column<int>(type: "int", nullable: false),
  74. DATATYPE = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  75. NOUPDATE = table.Column<bool>(type: "bit", nullable: false),
  76. ENABLED = table.Column<bool>(type: "bit", nullable: false),
  77. UPDATEUSER = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  78. UPDATETIME = table.Column<DateTime>(type: "datetime2", nullable: false),
  79. VER = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
  80. },
  81. constraints: table =>
  82. {
  83. table.PrimaryKey("PK_WCS_DATABLOCK", x => x.ID);
  84. table.ForeignKey(
  85. name: "FK_WCS_DATABLOCK_WCS_PLC_PLCID",
  86. column: x => x.PLCID,
  87. principalTable: "WCS_PLC",
  88. principalColumn: "ID",
  89. onDelete: ReferentialAction.Restrict);
  90. });
  91. migrationBuilder.CreateTable(
  92. name: "WCS_DEVICEITEM",
  93. columns: table => new
  94. {
  95. ID = table.Column<int>(type: "int", nullable: false)
  96. .Annotation("SqlServer:Identity", "1, 1"),
  97. DEVICECODE = table.Column<string>(type: "nvarchar(50)", nullable: false),
  98. DBID = table.Column<int>(type: "int", nullable: true),
  99. POSITION = table.Column<short>(type: "smallint", nullable: false),
  100. ENABLED = table.Column<bool>(type: "bit", nullable: false),
  101. UPDATEUSER = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  102. UPDATETIME = table.Column<DateTime>(type: "datetime2", nullable: false),
  103. VER = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
  104. },
  105. constraints: table =>
  106. {
  107. table.PrimaryKey("PK_WCS_DEVICEITEM", x => x.ID);
  108. table.ForeignKey(
  109. name: "FK_WCS_DEVICEITEM_WCS_DATABLOCK_DBID",
  110. column: x => x.DBID,
  111. principalTable: "WCS_DATABLOCK",
  112. principalColumn: "ID",
  113. onDelete: ReferentialAction.Restrict);
  114. table.ForeignKey(
  115. name: "FK_WCS_DEVICEITEM_WCS_DEVICE_DEVICECODE",
  116. column: x => x.DEVICECODE,
  117. principalTable: "WCS_DEVICE",
  118. principalColumn: "CODE",
  119. onDelete: ReferentialAction.Cascade);
  120. });
  121. migrationBuilder.CreateIndex(
  122. name: "IX_WCS_DATABLOCK_PLCID",
  123. table: "WCS_DATABLOCK",
  124. column: "PLCID");
  125. migrationBuilder.CreateIndex(
  126. name: "IX_WCS_DEVICEITEM_DBID",
  127. table: "WCS_DEVICEITEM",
  128. column: "DBID");
  129. migrationBuilder.CreateIndex(
  130. name: "IX_WCS_DEVICEITEM_DEVICECODE",
  131. table: "WCS_DEVICEITEM",
  132. column: "DEVICECODE");
  133. }
  134. protected override void Down(MigrationBuilder migrationBuilder)
  135. {
  136. migrationBuilder.DropTable(
  137. name: "WCS_DEVICEITEM");
  138. migrationBuilder.DropTable(
  139. name: "WCS_EXCEPTION");
  140. migrationBuilder.DropTable(
  141. name: "WCS_DATABLOCK");
  142. migrationBuilder.DropTable(
  143. name: "WCS_DEVICE");
  144. migrationBuilder.DropTable(
  145. name: "WCS_PLC");
  146. }
  147. }
  148. }