using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace RobotNet10.FleetManager.Data.Migrations.MapDb { /// public partial class AddMapDb : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Layouts", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), LayoutId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), LayoutName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), IsActive = table.Column(type: "bit", nullable: false), CreatedDate = table.Column(type: "datetime2", nullable: false), ModifiedDate = table.Column(type: "datetime2", nullable: false), CreatedBy = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), ModifiedBy = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true) }, constraints: table => { table.PrimaryKey("PK_Layouts", x => x.Id); }); migrationBuilder.CreateTable( name: "VehicleTypes", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), VehicleTypeId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), VehicleTypeName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), Specifications = table.Column(type: "nvarchar(max)", nullable: true), IsActive = table.Column(type: "bit", nullable: false), Actions = table.Column(type: "nvarchar(max)", nullable: true), CreatedDate = table.Column(type: "datetime2", nullable: false) }, constraints: table => { table.PrimaryKey("PK_VehicleTypes", x => x.Id); }); migrationBuilder.CreateTable( name: "LayoutVersions", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), LayoutId = table.Column(type: "uniqueidentifier", nullable: false), Version = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: false), LayoutDescription = table.Column(type: "nvarchar(max)", nullable: true), CreatedBy = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), CreatedDate = table.Column(type: "datetime2", nullable: false), IsActive = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_LayoutVersions", x => x.Id); table.ForeignKey( name: "FK_LayoutVersions_Layouts_LayoutId", column: x => x.LayoutId, principalTable: "Layouts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "LayoutLevels", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), VersionId = table.Column(type: "uniqueidentifier", nullable: false), LayoutLevelId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), LevelOrder = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_LayoutLevels", x => x.Id); table.ForeignKey( name: "FK_LayoutLevels_LayoutVersions_VersionId", column: x => x.VersionId, principalTable: "LayoutVersions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "LayoutLevelEditorSettings", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), LevelId = table.Column(type: "uniqueidentifier", nullable: false), EdgeMinLengthCreate = table.Column(type: "float", nullable: false), EdgeNameAutoGenerate = table.Column(type: "bit", nullable: false), NodeNameAutoGenerate = table.Column(type: "bit", nullable: false), NodeProximityRadius = table.Column(type: "float", nullable: false), OriginX = table.Column(type: "float", nullable: false), OriginY = table.Column(type: "float", nullable: false), Resolution = table.Column(type: "float", nullable: false), BoundsMinX = table.Column(type: "float", nullable: true), BoundsMaxX = table.Column(type: "float", nullable: true), BoundsMinY = table.Column(type: "float", nullable: true), BoundsMaxY = table.Column(type: "float", nullable: true), ImageWidth = table.Column(type: "float", nullable: true), ImageHeight = table.Column(type: "float", nullable: true), CreatedDate = table.Column(type: "datetime2", nullable: false), ModifiedDate = table.Column(type: "datetime2", nullable: false) }, constraints: table => { table.PrimaryKey("PK_LayoutLevelEditorSettings", x => x.Id); table.ForeignKey( name: "FK_LayoutLevelEditorSettings_LayoutLevels_LevelId", column: x => x.LevelId, principalTable: "LayoutLevels", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Nodes", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), LevelId = table.Column(type: "uniqueidentifier", nullable: false), NodeId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), NodeName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NodeDescription = table.Column(type: "nvarchar(max)", nullable: true), MapId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), X = table.Column(type: "float", nullable: false), Y = table.Column(type: "float", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Nodes", x => x.Id); table.ForeignKey( name: "FK_Nodes_LayoutLevels_LevelId", column: x => x.LevelId, principalTable: "LayoutLevels", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Stations", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), LevelId = table.Column(type: "uniqueidentifier", nullable: false), StationId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), StationName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), StationDescription = table.Column(type: "nvarchar(max)", nullable: true), StationHeight = table.Column(type: "float", nullable: true), X = table.Column(type: "float", nullable: false), Y = table.Column(type: "float", nullable: false), Theta = table.Column(type: "float", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Stations", x => x.Id); table.ForeignKey( name: "FK_Stations_LayoutLevels_LevelId", column: x => x.LevelId, principalTable: "LayoutLevels", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Edges", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), LevelId = table.Column(type: "uniqueidentifier", nullable: false), EdgeId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), StartNodeId = table.Column(type: "uniqueidentifier", nullable: false), EndNodeId = table.Column(type: "uniqueidentifier", nullable: false), EdgeName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), EdgeDescription = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Edges", x => x.Id); table.CheckConstraint("CK_Edges_DifferentNodes", "[StartNodeId] <> [EndNodeId]"); table.ForeignKey( name: "FK_Edges_LayoutLevels_LevelId", column: x => x.LevelId, principalTable: "LayoutLevels", principalColumn: "Id", onDelete: ReferentialAction.Cascade); 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: "NodeVehicleProperties", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), NodeId = table.Column(type: "uniqueidentifier", nullable: false), VehicleTypeId = table.Column(type: "uniqueidentifier", nullable: false), Theta = table.Column(type: "float", nullable: true), Actions = table.Column(type: "nvarchar(max)", nullable: true), AllowedDeviationXY = table.Column(type: "float", nullable: true), AllowedDeviationTheta = table.Column(type: "float", nullable: true) }, constraints: table => { table.PrimaryKey("PK_NodeVehicleProperties", x => x.Id); table.ForeignKey( name: "FK_NodeVehicleProperties_Nodes_NodeId", column: x => x.NodeId, principalTable: "Nodes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_NodeVehicleProperties_VehicleTypes_VehicleTypeId", column: x => x.VehicleTypeId, principalTable: "VehicleTypes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "StationInteractionNodes", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), StationId = table.Column(type: "uniqueidentifier", nullable: false), NodeId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_StationInteractionNodes", x => x.Id); table.ForeignKey( name: "FK_StationInteractionNodes_Nodes_NodeId", column: x => x.NodeId, principalTable: "Nodes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_StationInteractionNodes_Stations_StationId", column: x => x.StationId, principalTable: "Stations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "EdgeVehicleProperties", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), EdgeId = table.Column(type: "uniqueidentifier", nullable: false), VehicleTypeId = table.Column(type: "uniqueidentifier", nullable: false), VehicleOrientation = table.Column(type: "float", nullable: true), OrientationType = table.Column(type: "int", nullable: true), RotationAllowed = table.Column(type: "bit", nullable: true), RotationAtStartNodeAllowed = table.Column(type: "int", nullable: true), RotationAtEndNodeAllowed = table.Column(type: "int", nullable: true), MaxSpeed = table.Column(type: "float", nullable: true), MaxRotationSpeed = table.Column(type: "float", nullable: true), MinHeight = table.Column(type: "float", nullable: true), MaxHeight = table.Column(type: "float", nullable: true), LoadRestriction_Unloaded = table.Column(type: "bit", nullable: true), LoadRestriction_Loaded = table.Column(type: "bit", nullable: true), LoadRestriction_LoadSetNames = table.Column(type: "nvarchar(max)", nullable: true), TrajectoryDegree = table.Column(type: "int", nullable: true), TrajectoryControlPoint1X = table.Column(type: "float", nullable: true), TrajectoryControlPoint1Y = table.Column(type: "float", nullable: true), TrajectoryControlPoint2X = table.Column(type: "float", nullable: true), TrajectoryControlPoint2Y = table.Column(type: "float", nullable: true), Actions = table.Column(type: "nvarchar(max)", nullable: true), CorridorLeftWidth = table.Column(type: "float", nullable: true), CorridorRightWidth = table.Column(type: "float", nullable: true), CorridorRefPoint = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_EdgeVehicleProperties", x => x.Id); table.ForeignKey( name: "FK_EdgeVehicleProperties_Edges_EdgeId", column: x => x.EdgeId, principalTable: "Edges", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EdgeVehicleProperties_VehicleTypes_VehicleTypeId", column: x => x.VehicleTypeId, principalTable: "VehicleTypes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Edges_EdgeId", table: "Edges", column: "EdgeId"); migrationBuilder.CreateIndex( name: "IX_Edges_EndNodeId", table: "Edges", column: "EndNodeId"); migrationBuilder.CreateIndex( name: "IX_Edges_LevelId_EdgeId", table: "Edges", columns: new[] { "LevelId", "EdgeId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Edges_StartNodeId", table: "Edges", column: "StartNodeId"); migrationBuilder.CreateIndex( name: "IX_EdgeVehicleProperties_EdgeId", table: "EdgeVehicleProperties", column: "EdgeId"); migrationBuilder.CreateIndex( name: "IX_EdgeVehicleProperties_EdgeId_VehicleTypeId", table: "EdgeVehicleProperties", columns: new[] { "EdgeId", "VehicleTypeId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_EdgeVehicleProperties_VehicleTypeId", table: "EdgeVehicleProperties", column: "VehicleTypeId"); migrationBuilder.CreateIndex( name: "IX_LayoutLevelEditorSettings_LevelId", table: "LayoutLevelEditorSettings", column: "LevelId", unique: true); migrationBuilder.CreateIndex( name: "IX_LayoutLevels_LevelOrder", table: "LayoutLevels", column: "LevelOrder"); migrationBuilder.CreateIndex( name: "IX_LayoutLevels_VersionId_LayoutLevelId", table: "LayoutLevels", columns: new[] { "VersionId", "LayoutLevelId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Layouts_IsActive", table: "Layouts", column: "IsActive"); migrationBuilder.CreateIndex( name: "IX_Layouts_LayoutId", table: "Layouts", column: "LayoutId", unique: true); migrationBuilder.CreateIndex( name: "IX_LayoutVersions_IsActive", table: "LayoutVersions", column: "IsActive"); migrationBuilder.CreateIndex( name: "IX_LayoutVersions_LayoutId_Version", table: "LayoutVersions", columns: new[] { "LayoutId", "Version" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Nodes_LevelId_NodeId", table: "Nodes", columns: new[] { "LevelId", "NodeId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Nodes_MapId", table: "Nodes", column: "MapId"); migrationBuilder.CreateIndex( name: "IX_Nodes_NodeId", table: "Nodes", column: "NodeId"); migrationBuilder.CreateIndex( name: "IX_Nodes_X_Y", table: "Nodes", columns: new[] { "X", "Y" }); migrationBuilder.CreateIndex( name: "IX_NodeVehicleProperties_NodeId", table: "NodeVehicleProperties", column: "NodeId"); migrationBuilder.CreateIndex( name: "IX_NodeVehicleProperties_NodeId_VehicleTypeId", table: "NodeVehicleProperties", columns: new[] { "NodeId", "VehicleTypeId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_NodeVehicleProperties_VehicleTypeId", table: "NodeVehicleProperties", column: "VehicleTypeId"); migrationBuilder.CreateIndex( name: "IX_StationInteractionNodes_NodeId", table: "StationInteractionNodes", column: "NodeId"); migrationBuilder.CreateIndex( name: "IX_StationInteractionNodes_StationId", table: "StationInteractionNodes", column: "StationId"); migrationBuilder.CreateIndex( name: "IX_StationInteractionNodes_StationId_NodeId", table: "StationInteractionNodes", columns: new[] { "StationId", "NodeId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Stations_LevelId_StationId", table: "Stations", columns: new[] { "LevelId", "StationId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Stations_StationId", table: "Stations", column: "StationId"); migrationBuilder.CreateIndex( name: "IX_VehicleTypes_IsActive", table: "VehicleTypes", column: "IsActive"); migrationBuilder.CreateIndex( name: "IX_VehicleTypes_VehicleTypeId", table: "VehicleTypes", column: "VehicleTypeId", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "EdgeVehicleProperties"); migrationBuilder.DropTable( name: "LayoutLevelEditorSettings"); migrationBuilder.DropTable( name: "NodeVehicleProperties"); migrationBuilder.DropTable( name: "StationInteractionNodes"); migrationBuilder.DropTable( name: "Edges"); migrationBuilder.DropTable( name: "VehicleTypes"); migrationBuilder.DropTable( name: "Stations"); migrationBuilder.DropTable( name: "Nodes"); migrationBuilder.DropTable( name: "LayoutLevels"); migrationBuilder.DropTable( name: "LayoutVersions"); migrationBuilder.DropTable( name: "Layouts"); } } }