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(type: "nvarchar(50)", maxLength: 50, nullable: false), NAME = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), TYPE = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), ENABLED = table.Column(type: "bit", nullable: false), UPDATEUSER = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), UPDATETIME = table.Column(type: "datetime2", nullable: false), VER = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), MSG = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), STARTTIME = table.Column(type: "datetime2", nullable: false), TIMES = table.Column(type: "int", nullable: false), ENABLED = table.Column(type: "bit", nullable: false), UPDATEUSER = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), UPDATETIME = table.Column(type: "datetime2", nullable: false), VER = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), NAME = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), IP = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), PORT = table.Column(type: "int", nullable: false), SLOT = table.Column(type: "int", nullable: false), RACK = table.Column(type: "int", nullable: false), ENABLED = table.Column(type: "bit", nullable: false), UPDATEUSER = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), UPDATETIME = table.Column(type: "datetime2", nullable: false), VER = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), NAME = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), PLCID = table.Column(type: "int", nullable: true), NO = table.Column(type: "int", nullable: false), LENGTH = table.Column(type: "int", nullable: false), DATALENGTH = table.Column(type: "int", nullable: false), DATATYPE = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), NOUPDATE = table.Column(type: "bit", nullable: false), ENABLED = table.Column(type: "bit", nullable: false), UPDATEUSER = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), UPDATETIME = table.Column(type: "datetime2", nullable: false), VER = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), DEVICECODE = table.Column(type: "nvarchar(50)", nullable: false), DBID = table.Column(type: "int", nullable: true), POSITION = table.Column(type: "smallint", nullable: false), ENABLED = table.Column(type: "bit", nullable: false), UPDATEUSER = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), UPDATETIME = table.Column(type: "datetime2", nullable: false), VER = table.Column(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"); } } }