123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- namespace WCS.Service.Migrations
- {
- public partial class Init : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "WCS_DEVICE",
- columns: table => new
- {
- CODE = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
- NAME = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
- TYPE = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
- ENABLED = table.Column<bool>(type: "bit", nullable: false),
- UPDATEUSER = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
- UPDATETIME = table.Column<DateTime>(type: "datetime2", nullable: false),
- VER = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_WCS_DEVICE", x => x.CODE);
- });
- migrationBuilder.CreateTable(
- name: "WCS_EXCEPTION",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- MSG = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
- STARTTIME = table.Column<DateTime>(type: "datetime2", nullable: false),
- TIMES = table.Column<int>(type: "int", nullable: false),
- ENABLED = table.Column<bool>(type: "bit", nullable: false),
- UPDATEUSER = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
- UPDATETIME = table.Column<DateTime>(type: "datetime2", nullable: false),
- VER = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_WCS_EXCEPTION", x => x.ID);
- });
- migrationBuilder.CreateTable(
- name: "WCS_PLC",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- NAME = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
- IP = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
- PORT = table.Column<int>(type: "int", nullable: false),
- SLOT = table.Column<int>(type: "int", nullable: false),
- RACK = table.Column<int>(type: "int", nullable: false),
- ENABLED = table.Column<bool>(type: "bit", nullable: false),
- UPDATEUSER = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
- UPDATETIME = table.Column<DateTime>(type: "datetime2", nullable: false),
- VER = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_WCS_PLC", x => x.ID);
- });
- migrationBuilder.CreateTable(
- name: "WCS_DATABLOCK",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- NAME = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
- PLCID = table.Column<int>(type: "int", nullable: true),
- NO = table.Column<int>(type: "int", nullable: false),
- LENGTH = table.Column<int>(type: "int", nullable: false),
- DATALENGTH = table.Column<int>(type: "int", nullable: false),
- DATATYPE = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
- NOUPDATE = table.Column<bool>(type: "bit", nullable: false),
- ENABLED = table.Column<bool>(type: "bit", nullable: false),
- UPDATEUSER = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
- UPDATETIME = table.Column<DateTime>(type: "datetime2", nullable: false),
- VER = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_WCS_DATABLOCK", x => x.ID);
- table.ForeignKey(
- name: "FK_WCS_DATABLOCK_WCS_PLC_PLCID",
- column: x => x.PLCID,
- principalTable: "WCS_PLC",
- principalColumn: "ID",
- onDelete: ReferentialAction.Restrict);
- });
- migrationBuilder.CreateTable(
- name: "WCS_DEVICEITEM",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- DEVICECODE = table.Column<string>(type: "nvarchar(50)", nullable: false),
- DBID = table.Column<int>(type: "int", nullable: true),
- POSITION = table.Column<short>(type: "smallint", nullable: false),
- ENABLED = table.Column<bool>(type: "bit", nullable: false),
- UPDATEUSER = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
- UPDATETIME = table.Column<DateTime>(type: "datetime2", nullable: false),
- VER = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_WCS_DEVICEITEM", x => x.ID);
- table.ForeignKey(
- name: "FK_WCS_DEVICEITEM_WCS_DATABLOCK_DBID",
- column: x => x.DBID,
- principalTable: "WCS_DATABLOCK",
- principalColumn: "ID",
- onDelete: ReferentialAction.Restrict);
- table.ForeignKey(
- name: "FK_WCS_DEVICEITEM_WCS_DEVICE_DEVICECODE",
- column: x => x.DEVICECODE,
- principalTable: "WCS_DEVICE",
- principalColumn: "CODE",
- onDelete: ReferentialAction.Cascade);
- });
- migrationBuilder.CreateIndex(
- name: "IX_WCS_DATABLOCK_PLCID",
- table: "WCS_DATABLOCK",
- column: "PLCID");
- migrationBuilder.CreateIndex(
- name: "IX_WCS_DEVICEITEM_DBID",
- table: "WCS_DEVICEITEM",
- column: "DBID");
- migrationBuilder.CreateIndex(
- name: "IX_WCS_DEVICEITEM_DEVICECODE",
- table: "WCS_DEVICEITEM",
- column: "DEVICECODE");
- }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "WCS_DEVICEITEM");
- migrationBuilder.DropTable(
- name: "WCS_EXCEPTION");
- migrationBuilder.DropTable(
- name: "WCS_DATABLOCK");
- migrationBuilder.DropTable(
- name: "WCS_DEVICE");
- migrationBuilder.DropTable(
- name: "WCS_PLC");
- }
- }
- }
|