using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace RobotNet.MapManager.Data.Migrations { /// public partial class AddMapdb : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Maps", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(64)", nullable: false), Description = table.Column(type: "ntext", nullable: true), VersionId = table.Column(type: "uniqueidentifier", nullable: false), OriginX = table.Column(type: "float", nullable: false), OriginY = table.Column(type: "float", nullable: false), Resolution = table.Column(type: "float", nullable: false), ViewX = table.Column(type: "float", nullable: false), ViewY = table.Column(type: "float", nullable: false), ViewWidth = table.Column(type: "float", nullable: false), ViewHeight = table.Column(type: "float", nullable: false), ImageWidth = table.Column(type: "float", nullable: false), ImageHeight = table.Column(type: "float", nullable: false), NodeCount = table.Column(type: "BigInt", nullable: false), Active = table.Column(type: "bit", nullable: false), VDA5050 = table.Column(type: "nvarchar(max)", nullable: true), NodeNameAutoGenerate = table.Column(type: "bit", nullable: false), NodeNameTemplateDefault = table.Column(type: "nvarchar(64)", nullable: true), NodeAllowedDeviationXyDefault = table.Column(type: "float", nullable: false), NodeAllowedDeviationThetaDefault = table.Column(type: "float", nullable: false), EdgeMinLengthDefault = table.Column(type: "float", nullable: false), EdgeStraightMaxSpeedDefault = table.Column(type: "float", nullable: false), EdgeCurveMaxSpeedDefault = table.Column(type: "float", nullable: false), EdgeMaxHeightDefault = table.Column(type: "float", nullable: false), EdgeMinHeightDefault = table.Column(type: "float", nullable: false), EdgeMaxRoataionSpeedDefault = table.Column(type: "float", nullable: false), EdgeDirectionAllowedDefault = table.Column(type: "tinyint", nullable: false), EdgeRotationAllowedDefault = table.Column(type: "bit", nullable: false), EdgeAllowedDeviationXyDefault = table.Column(type: "float", nullable: false), EdgeAllowedDeviationThetaDefault = table.Column(type: "float", nullable: false), ZoneMinSquareDefault = table.Column(type: "float", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Maps", x => x.Id); }); migrationBuilder.CreateTable( name: "Actions", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), MapId = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(64)", nullable: true), Content = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Actions", x => x.Id); table.ForeignKey( name: "FK_Actions_Maps_MapId", column: x => x.MapId, principalTable: "Maps", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ElementModels", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), MapId = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(64)", nullable: true), Width = table.Column(type: "float", nullable: false), Height = table.Column(type: "float", nullable: false), Image1Width = table.Column(type: "int", nullable: false), Image1Height = table.Column(type: "int", nullable: false), Image2Width = table.Column(type: "int", nullable: false), Image2Height = table.Column(type: "int", nullable: false), Content = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ElementModels", x => x.Id); table.ForeignKey( name: "FK_ElementModels_Maps_MapId", column: x => x.MapId, principalTable: "Maps", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Nodes", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), MapId = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(64)", nullable: true), X = table.Column(type: "float", nullable: false), Y = table.Column(type: "float", nullable: false), Theta = table.Column(type: "float", nullable: false), AllowedDeviationXy = table.Column(type: "float", nullable: false), AllowedDeviationTheta = table.Column(type: "float", nullable: false), Actions = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Nodes", x => x.Id); table.ForeignKey( name: "FK_Nodes_Maps_MapId", column: x => x.MapId, principalTable: "Maps", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Zones", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), MapId = table.Column(type: "uniqueidentifier", nullable: false), Type = table.Column(type: "int", nullable: false), X1 = table.Column(type: "float", nullable: false), Y1 = table.Column(type: "float", nullable: false), X2 = table.Column(type: "float", nullable: false), Y2 = table.Column(type: "float", nullable: false), X3 = table.Column(type: "float", nullable: false), Y3 = table.Column(type: "float", nullable: false), X4 = table.Column(type: "float", nullable: false), Y4 = table.Column(type: "float", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Zones", x => x.Id); table.ForeignKey( name: "FK_Zones_Maps_MapId", column: x => x.MapId, principalTable: "Maps", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Edges", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), MapId = table.Column(type: "uniqueidentifier", nullable: false), StartNodeId = table.Column(type: "uniqueidentifier", nullable: false), EndNodeId = table.Column(type: "uniqueidentifier", nullable: false), ControlPoint1X = table.Column(type: "float", nullable: false), ControlPoint1Y = table.Column(type: "float", nullable: false), ControlPoint2X = table.Column(type: "float", nullable: false), ControlPoint2Y = table.Column(type: "float", nullable: false), TrajectoryDegree = table.Column(type: "tinyint", nullable: false), MaxHeight = table.Column(type: "float", nullable: false), MinHeight = table.Column(type: "float", nullable: false), DirectionAllowed = table.Column(type: "tinyint", nullable: false), RotationAllowed = table.Column(type: "bit", nullable: false), MaxRotationSpeed = table.Column(type: "float", nullable: false), MaxSpeed = table.Column(type: "float", nullable: false), AllowedDeviationXy = table.Column(type: "float", nullable: false), AllowedDeviationTheta = table.Column(type: "float", nullable: false), Actions = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Edges", x => x.Id); table.ForeignKey( name: "FK_Edges_Maps_MapId", column: x => x.MapId, principalTable: "Maps", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Edges_Nodes_EndNodeId", column: x => x.EndNodeId, principalTable: "Nodes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Edges_Nodes_StartNodeId", column: x => x.StartNodeId, principalTable: "Nodes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Elements", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), MapId = table.Column(type: "uniqueidentifier", nullable: false), ModelId = table.Column(type: "uniqueidentifier", nullable: false), NodeId = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(64)", nullable: true), IsOpen = table.Column(type: "bit", nullable: false), OffsetX = table.Column(type: "float", nullable: false), OffsetY = table.Column(type: "float", nullable: false), Content = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Elements", x => x.Id); table.ForeignKey( name: "FK_Elements_ElementModels_ModelId", column: x => x.ModelId, principalTable: "ElementModels", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Elements_Maps_MapId", column: x => x.MapId, principalTable: "Maps", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Elements_Nodes_NodeId", column: x => x.NodeId, principalTable: "Nodes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_Action_MapId_Name", table: "Actions", columns: new[] { "MapId", "Name" }); migrationBuilder.CreateIndex( name: "IX_Edge_MapId", table: "Edges", column: "MapId"); migrationBuilder.CreateIndex( name: "IX_Edges_EndNodeId", table: "Edges", column: "EndNodeId"); migrationBuilder.CreateIndex( name: "IX_Edges_StartNodeId", table: "Edges", column: "StartNodeId"); migrationBuilder.CreateIndex( name: "IX_ElementModel_MapId_Name", table: "ElementModels", columns: new[] { "MapId", "Name" }); migrationBuilder.CreateIndex( name: "IX_Element_MapId_ModelId", table: "Elements", columns: new[] { "MapId", "ModelId" }); migrationBuilder.CreateIndex( name: "IX_Elements_ModelId", table: "Elements", column: "ModelId"); migrationBuilder.CreateIndex( name: "IX_Elements_NodeId", table: "Elements", column: "NodeId", unique: true); migrationBuilder.CreateIndex( name: "IX_Node_MapId_Name", table: "Nodes", columns: new[] { "MapId", "Name" }); migrationBuilder.CreateIndex( name: "IX_Zone_MapId", table: "Zones", column: "MapId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Actions"); migrationBuilder.DropTable( name: "Edges"); migrationBuilder.DropTable( name: "Elements"); migrationBuilder.DropTable( name: "Zones"); migrationBuilder.DropTable( name: "ElementModels"); migrationBuilder.DropTable( name: "Nodes"); migrationBuilder.DropTable( name: "Maps"); } } }