From deb65bcd5adec4c0adb283a3095abe31e3f1b5a9 Mon Sep 17 00:00:00 2001 From: andchiind Date: Tue, 18 Jul 2023 15:20:29 +0200 Subject: [PATCH 1/4] Store error strings from Isar --- backend/api/Database/Models/Inspection.cs | 4 ++ backend/api/Database/Models/MissionRun.cs | 4 ++ backend/api/Database/Models/MissionTask.cs | 4 ++ backend/api/EventHandlers/MqttEventHandler.cs | 12 +++- backend/api/MQTT/MessageModels/IsarMission.cs | 6 ++ backend/api/MQTT/MessageModels/IsarStep.cs | 6 ++ backend/api/MQTT/MessageModels/IsarTask.cs | 6 ++ backend/api/Services/MissionRunService.cs | 65 +++++++++++++++++++ 8 files changed, 104 insertions(+), 3 deletions(-) diff --git a/backend/api/Database/Models/Inspection.cs b/backend/api/Database/Models/Inspection.cs index a637c055f..cd6847d3e 100644 --- a/backend/api/Database/Models/Inspection.cs +++ b/backend/api/Database/Models/Inspection.cs @@ -52,6 +52,10 @@ or InspectionStatus.Successful [MaxLength(250)] public string? InspectionUrl { get; set; } + public string? ErrorReason { get; set; } + + public string? ErrorDescription { get; set; } + public DateTimeOffset? StartTime { get; private set; } public DateTimeOffset? EndTime { get; private set; } diff --git a/backend/api/Database/Models/MissionRun.cs b/backend/api/Database/Models/MissionRun.cs index dd104464a..380986b4b 100644 --- a/backend/api/Database/Models/MissionRun.cs +++ b/backend/api/Database/Models/MissionRun.cs @@ -77,6 +77,10 @@ or MissionStatus.PartiallySuccessful public MapMetadata? MapMetadata { get; set; } + public string? ErrorReason { get; set; } + + public string? ErrorDescription { get; set; } + public DateTimeOffset? StartTime { get; private set; } public DateTimeOffset? EndTime { get; private set; } diff --git a/backend/api/Database/Models/MissionTask.cs b/backend/api/Database/Models/MissionTask.cs index 3e30e8273..d80e6045b 100644 --- a/backend/api/Database/Models/MissionTask.cs +++ b/backend/api/Database/Models/MissionTask.cs @@ -62,6 +62,10 @@ or TaskStatus.Successful or TaskStatus.Failed or TaskStatus.PartiallySuccessful; + public string? ErrorReason { get; set; } + + public string? ErrorDescription { get; set; } + public DateTimeOffset? StartTime { get; private set; } public DateTimeOffset? EndTime { get; private set; } diff --git a/backend/api/EventHandlers/MqttEventHandler.cs b/backend/api/EventHandlers/MqttEventHandler.cs index b832e4eb0..88174fc9c 100644 --- a/backend/api/EventHandlers/MqttEventHandler.cs +++ b/backend/api/EventHandlers/MqttEventHandler.cs @@ -270,7 +270,9 @@ private async void OnMissionUpdate(object? sender, MqttReceivedArgs mqttArgs) var flotillaMissionRun = await missionRunService.UpdateMissionRunStatusByIsarMissionId( isarMission.MissionId, - status + status, + isarMission.ErrorReason, + isarMission.ErrorDescription ); if (flotillaMissionRun is null) @@ -369,7 +371,9 @@ private async void OnTaskUpdate(object? sender, MqttReceivedArgs mqttArgs) bool success = await missionRunService.UpdateTaskStatusByIsarTaskId( task.MissionId, task.TaskId, - status + status, + task.ErrorReason, + task.ErrorDescription ); if (success) @@ -417,7 +421,9 @@ private async void OnStepUpdate(object? sender, MqttReceivedArgs mqttArgs) step.MissionId, step.TaskId, step.StepId, - status + status, + step.ErrorReason, + step.ErrorDescription ); if (success) diff --git a/backend/api/MQTT/MessageModels/IsarMission.cs b/backend/api/MQTT/MessageModels/IsarMission.cs index f32f8c6ba..a8f4044bf 100644 --- a/backend/api/MQTT/MessageModels/IsarMission.cs +++ b/backend/api/MQTT/MessageModels/IsarMission.cs @@ -19,5 +19,11 @@ public class IsarMissionMessage : MqttMessage [JsonPropertyName("timestamp")] public DateTime Timestamp { get; set; } + + [JsonPropertyName("error_reason")] + public string ErrorReason { get; set; } + + [JsonPropertyName("error_description")] + public string ErrorDescription { get; set; } } } diff --git a/backend/api/MQTT/MessageModels/IsarStep.cs b/backend/api/MQTT/MessageModels/IsarStep.cs index 7106ca56e..45ee5eee7 100644 --- a/backend/api/MQTT/MessageModels/IsarStep.cs +++ b/backend/api/MQTT/MessageModels/IsarStep.cs @@ -28,5 +28,11 @@ public class IsarStepMessage : MqttMessage [JsonPropertyName("timestamp")] public DateTime Timestamp { get; set; } + + [JsonPropertyName("error_reason")] + public string ErrorReason { get; set; } + + [JsonPropertyName("error_description")] + public string ErrorDescription { get; set; } } } diff --git a/backend/api/MQTT/MessageModels/IsarTask.cs b/backend/api/MQTT/MessageModels/IsarTask.cs index e442b8600..ab0a9523f 100644 --- a/backend/api/MQTT/MessageModels/IsarTask.cs +++ b/backend/api/MQTT/MessageModels/IsarTask.cs @@ -22,5 +22,11 @@ public class IsarTaskMessage : MqttMessage [JsonPropertyName("timestamp")] public DateTime Timestamp { get; set; } + + [JsonPropertyName("error_reason")] + public string ErrorReason { get; set; } + + [JsonPropertyName("error_description")] + public string ErrorDescription { get; set; } } } diff --git a/backend/api/Services/MissionRunService.cs b/backend/api/Services/MissionRunService.cs index 9a3b269aa..88c980e48 100644 --- a/backend/api/Services/MissionRunService.cs +++ b/backend/api/Services/MissionRunService.cs @@ -25,12 +25,27 @@ public interface IMissionRunService MissionStatus missionStatus ); + public abstract Task UpdateMissionRunStatusByIsarMissionId( + string isarMissionId, + MissionStatus missionStatus, + string? errorReason, + string? errorDescription + ); + public abstract Task UpdateTaskStatusByIsarTaskId( string isarMissionId, string isarTaskId, IsarTaskStatus taskStatus ); + public abstract Task UpdateTaskStatusByIsarTaskId( + string isarMissionId, + string isarTaskId, + IsarTaskStatus taskStatus, + string? errorReason, + string? errorDescription + ); + public abstract Task UpdateStepStatusByIsarStepId( string isarMissionId, string isarTaskId, @@ -38,6 +53,15 @@ public abstract Task UpdateStepStatusByIsarStepId( IsarStepStatus stepStatus ); + public abstract Task UpdateStepStatusByIsarStepId( + string isarMissionId, + string isarTaskId, + string isarStepId, + IsarStepStatus stepStatus, + string? errorReason, + string? errorDescription + ); + public abstract Task Delete(string id); } @@ -155,6 +179,16 @@ public async Task Update(MissionRun missionRun) string isarMissionId, MissionStatus missionStatus ) + { + return await UpdateMissionRunStatusByIsarMissionId(isarMissionId, missionStatus, null, null); + } + + public async Task UpdateMissionRunStatusByIsarMissionId( + string isarMissionId, + MissionStatus missionStatus, + string? errorReason, + string? errorDescription + ) { var missionRun = await ReadByIsarMissionId(isarMissionId); if (missionRun is null) @@ -167,6 +201,8 @@ MissionStatus missionStatus } missionRun.Status = missionStatus; + missionRun.ErrorReason = errorReason; + missionRun.ErrorDescription = errorDescription; await _context.SaveChangesAsync(); @@ -178,6 +214,17 @@ public async Task UpdateTaskStatusByIsarTaskId( string isarTaskId, IsarTaskStatus taskStatus ) + { + return await UpdateTaskStatusByIsarTaskId(isarMissionId, isarTaskId, taskStatus, null, null); + } + + public async Task UpdateTaskStatusByIsarTaskId( + string isarMissionId, + string isarTaskId, + IsarTaskStatus taskStatus, + string? errorReason, + string? errorDescription + ) { var missionRun = await ReadByIsarMissionId(isarMissionId); if (missionRun is null) @@ -219,6 +266,9 @@ var taskItem in missionRun.Tasks.Where( } } + task.ErrorReason = errorReason; + task.ErrorDescription = errorDescription; + await _context.SaveChangesAsync(); return true; @@ -230,6 +280,18 @@ public async Task UpdateStepStatusByIsarStepId( string isarStepId, IsarStepStatus stepStatus ) + { + return await UpdateStepStatusByIsarStepId(isarMissionId, isarTaskId, isarStepId, stepStatus, null, null); + } + + public async Task UpdateStepStatusByIsarStepId( + string isarMissionId, + string isarTaskId, + string isarStepId, + IsarStepStatus stepStatus, + string? errorReason, + string? errorDescription + ) { var missionRun = await ReadByIsarMissionId(isarMissionId); if (missionRun is null) @@ -265,6 +327,9 @@ IsarStepStatus stepStatus inspection.UpdateStatus(stepStatus); + inspection.ErrorReason = errorReason; + inspection.ErrorDescription = errorDescription; + await _context.SaveChangesAsync(); return true; From 2ed29cc5433f599abf204f3306727915296540a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Chirico=20Indreb=C3=B8?= Date: Wed, 19 Jul 2023 10:41:09 +0200 Subject: [PATCH 2/4] Return Mission Dto in controller --- backend/api/Controllers/MissionController.cs | 14 ++-- .../api/Controllers/Models/InspectionDto.cs | 45 +++++++++++++ .../api/Controllers/Models/MissionRunDto.cs | 65 +++++++++++++++++++ .../api/Controllers/Models/MissionTaskDto.cs | 57 ++++++++++++++++ backend/api/Controllers/RobotController.cs | 7 ++ backend/api/Database/Models/Inspection.cs | 10 +++ backend/api/Database/Models/MissionRun.cs | 27 ++++++++ backend/api/Database/Models/MissionTask.cs | 27 ++++++++ backend/api/Utilities/IsarErrorHandling.cs | 19 ++++++ 9 files changed, 265 insertions(+), 6 deletions(-) create mode 100644 backend/api/Controllers/Models/InspectionDto.cs create mode 100644 backend/api/Controllers/Models/MissionRunDto.cs create mode 100644 backend/api/Controllers/Models/MissionTaskDto.cs create mode 100644 backend/api/Utilities/IsarErrorHandling.cs diff --git a/backend/api/Controllers/MissionController.cs b/backend/api/Controllers/MissionController.cs index 6561ac49c..4853523b8 100644 --- a/backend/api/Controllers/MissionController.cs +++ b/backend/api/Controllers/MissionController.cs @@ -54,12 +54,12 @@ IStidService stidService /// [HttpGet("runs")] [Authorize(Roles = Role.Any)] - [ProducesResponseType(typeof(IList), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(IList), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task>> GetMissionRuns( + public async Task>> GetMissionRuns( [FromQuery] MissionRunQueryStringParameters parameters ) { @@ -102,7 +102,9 @@ [FromQuery] MissionRunQueryStringParameters parameters JsonSerializer.Serialize(metadata) ); - return Ok(missionRuns); + var missionRunDtos = missionRuns.Select(m => new MissionRunDto(m)); + + return Ok(missionRunDtos); } /// @@ -157,17 +159,17 @@ [FromQuery] MissionDefinitionQueryStringParameters parameters [HttpGet] [Authorize(Roles = Role.Any)] [Route("runs/{id}")] - [ProducesResponseType(typeof(MissionRun), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(MissionRunDto), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> GetMissionRunById([FromRoute] string id) + public async Task> GetMissionRunById([FromRoute] string id) { var missioRun = await _missionRunService.ReadById(id); if (missioRun == null) return NotFound($"Could not find mission run with id {id}"); - return Ok(missioRun); + return Ok(new MissionRunDto(missioRun)); } /// diff --git a/backend/api/Controllers/Models/InspectionDto.cs b/backend/api/Controllers/Models/InspectionDto.cs new file mode 100644 index 000000000..9d0df3f98 --- /dev/null +++ b/backend/api/Controllers/Models/InspectionDto.cs @@ -0,0 +1,45 @@ +using Api.Database.Models; + +#pragma warning disable CS8618 +namespace Api.Controllers.Models +{ + public class InspectionDto + { + public InspectionDto(Inspection inspection) + { + Id = inspection.Id; + IsarStepId = inspection.IsarStepId; + Status = inspection.Status; + IsCompleted = inspection.IsCompleted; + InspectionType = inspection.InspectionType; + VideoDuration = inspection.VideoDuration; + AnalysisTypes = inspection.AnalysisTypes; + InspectionUrl = inspection.InspectionUrl; + Error = inspection.GetError(); + StartTime = inspection.StartTime; + EndTime = inspection.EndTime; + } + + public string Id { get; set; } + + public string? IsarStepId { get; set; } + + public InspectionStatus Status { get; set; } + + public bool IsCompleted { get; set; } + + public InspectionType InspectionType { get; set; } + + public float? VideoDuration { get; set; } + + public string? AnalysisTypes { get; set; } + + public string? InspectionUrl { get; set; } + + public string? Error { get; set; } + + public DateTimeOffset? StartTime { get; private set; } + + public DateTimeOffset? EndTime { get; private set; } + } +} diff --git a/backend/api/Controllers/Models/MissionRunDto.cs b/backend/api/Controllers/Models/MissionRunDto.cs new file mode 100644 index 000000000..fa635a4ff --- /dev/null +++ b/backend/api/Controllers/Models/MissionRunDto.cs @@ -0,0 +1,65 @@ +using Api.Database.Models; + +#pragma warning disable CS8618 +namespace Api.Controllers.Models +{ + public class MissionRunDto + { + public MissionRunDto(MissionRun mission) + { + Id = mission.Id; + IsarMissionId = mission.IsarMissionId; + Name = mission.Name; + Description = mission.Description; + StatusReason = mission.StatusReason; + Comment = mission.Comment; + InstallationCode = mission.InstallationCode; + Robot = mission.Robot; + Status = mission.Status; + IsCompleted = mission.IsCompleted; + MapMetadata = mission.MapMetadata; + Error = mission.GetError(); // TODO: rethink whether nested errors are needed here + DesiredStartTime = mission.DesiredStartTime; + StartTime = mission.StartTime; + EndTime = mission.EndTime; + EstimatedDuration = mission.EstimatedDuration; + Tasks = mission.Tasks.Select(t => new MissionTaskDto(t)).ToList(); + } + + public string Id { get; set; } + + public int? EchoMissionId { get; set; } + + public string? IsarMissionId { get; set; } + + public string Name { get; set; } + + public string? Description { get; set; } + + public string? StatusReason { get; set; } + + public string? Comment { get; set; } + + public string InstallationCode { get; set; } + + public Robot Robot { get; set; } + + public MissionStatus Status { get; set; } + + public bool IsCompleted { get; set; } + + public MapMetadata? MapMetadata { get; set; } + + public string? Error { get; set; } + + public DateTimeOffset DesiredStartTime { get; set; } + + public DateTimeOffset? StartTime { get; private set; } + + public DateTimeOffset? EndTime { get; private set; } + + public uint? EstimatedDuration { get; set; } + + public IList Tasks { get; set; } + } +} diff --git a/backend/api/Controllers/Models/MissionTaskDto.cs b/backend/api/Controllers/Models/MissionTaskDto.cs new file mode 100644 index 000000000..0408a1313 --- /dev/null +++ b/backend/api/Controllers/Models/MissionTaskDto.cs @@ -0,0 +1,57 @@ +using Api.Database.Models; + +#pragma warning disable CS8618 +namespace Api.Controllers.Models +{ + public class MissionTaskDto + { + public MissionTaskDto(MissionTask task) + { + Id = task.Id; + IsarTaskId = task.IsarTaskId; + TaskOrder = task.TaskOrder; + TagId = task.TagId; + Description = task.Description; + EchoTagLink = task.EchoTagLink; + InspectionTarget = task.InspectionTarget; + RobotPose = task.RobotPose; + EchoPoseId = task.EchoPoseId; + Status = task.Status; + IsCompleted = task.IsCompleted; + Error = task.GetError(); // TODO: rethink whether nested errors are needed here + StartTime = task.StartTime; + EndTime = task.EndTime; + Inspections = task.Inspections.Select(i => new InspectionDto(i)).ToList(); + } + + public string Id { get; set; } + + public string? IsarTaskId { get; set; } + + public int TaskOrder { get; set; } + + public string? TagId { get; set; } + + public string? Description { get; set; } + + public Uri? EchoTagLink { get; set; } + + public Position InspectionTarget { get; set; } + + public Pose RobotPose { get; set; } + + public int? EchoPoseId { get; set; } + + public Database.Models.TaskStatus Status { get; set; } + + public bool IsCompleted { get; set; } + + public string? Error { get; set; } + + public DateTimeOffset? StartTime { get; private set; } + + public DateTimeOffset? EndTime { get; private set; } + + public IList Inspections { get; set; } + } +} diff --git a/backend/api/Controllers/RobotController.cs b/backend/api/Controllers/RobotController.cs index e1131aef8..140f5f983 100644 --- a/backend/api/Controllers/RobotController.cs +++ b/backend/api/Controllers/RobotController.cs @@ -368,6 +368,13 @@ [FromRoute] string missionRunId return NotFound("Mission not found"); } + string? missionRunError = missionRun.GetError(); + if (missionRunError != null) + { + _logger.LogError(new MissionException(missionRunError), $"Error in ISAR mission: {missionRunError}"); + return StatusCode(StatusCodes.Status502BadGateway, $"Error in ISAR mission: {missionRunError}"); + } + IsarMission isarMission; try { diff --git a/backend/api/Database/Models/Inspection.cs b/backend/api/Database/Models/Inspection.cs index cd6847d3e..406e2aa74 100644 --- a/backend/api/Database/Models/Inspection.cs +++ b/backend/api/Database/Models/Inspection.cs @@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations.Schema; using Api.Controllers.Models; using Api.Services.Models; +using Api.Utilities; using Microsoft.EntityFrameworkCore; #pragma warning disable CS8618 @@ -56,6 +57,15 @@ or InspectionStatus.Successful public string? ErrorDescription { get; set; } + public string? GetError() + { + if (ErrorReason != null) + { + return IsarErrorHandling.MapIsarError(ErrorReason); + } + return null; + } + public DateTimeOffset? StartTime { get; private set; } public DateTimeOffset? EndTime { get; private set; } diff --git a/backend/api/Database/Models/MissionRun.cs b/backend/api/Database/Models/MissionRun.cs index 380986b4b..ec811c378 100644 --- a/backend/api/Database/Models/MissionRun.cs +++ b/backend/api/Database/Models/MissionRun.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Api.Services.Models; +using Api.Utilities; #pragma warning disable CS8618 namespace Api.Database.Models @@ -81,6 +82,32 @@ or MissionStatus.PartiallySuccessful public string? ErrorDescription { get; set; } + public bool HasNestedError() + { + if (ErrorReason != null) + { + return true; + } + else + { + foreach (var task in Tasks) + { + if (task.HasNestedError()) + return true; + } + } + return false; + } + + public string? GetError() + { + if (ErrorReason != null) + { + return IsarErrorHandling.MapIsarError(ErrorReason); + } + return null; + } + public DateTimeOffset? StartTime { get; private set; } public DateTimeOffset? EndTime { get; private set; } diff --git a/backend/api/Database/Models/MissionTask.cs b/backend/api/Database/Models/MissionTask.cs index d80e6045b..8787aaf05 100644 --- a/backend/api/Database/Models/MissionTask.cs +++ b/backend/api/Database/Models/MissionTask.cs @@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations.Schema; using Api.Controllers.Models; using Api.Services.Models; +using Api.Utilities; using Microsoft.EntityFrameworkCore; #pragma warning disable CS8618 @@ -66,6 +67,32 @@ or TaskStatus.Failed public string? ErrorDescription { get; set; } + public bool HasNestedError() + { + if (ErrorReason != null) + { + return true; + } + else + { + foreach (var inspection in Inspections) + { + if (inspection.GetError() != null) + return true; + } + } + return false; + } + + public string? GetError() + { + if (ErrorReason != null) + { + return IsarErrorHandling.MapIsarError(ErrorReason); + } + return null; + } + public DateTimeOffset? StartTime { get; private set; } public DateTimeOffset? EndTime { get; private set; } diff --git a/backend/api/Utilities/IsarErrorHandling.cs b/backend/api/Utilities/IsarErrorHandling.cs new file mode 100644 index 000000000..5a6bc1dd7 --- /dev/null +++ b/backend/api/Utilities/IsarErrorHandling.cs @@ -0,0 +1,19 @@ +namespace Api.Utilities +{ + public static class IsarErrorHandling + { + public static string? MapIsarError(string isarErrorReason) + { + if (!isarErrorMapping.ContainsKey(isarErrorReason)) + { + return null; + } + return isarErrorMapping[isarErrorReason]; + } + + private static readonly Dictionary isarErrorMapping = new() + { + {"robot_communication_exception", "The step failed as the system was not able to communicate with the robot"} + }; + } +} From 7eea767f9b39c9be8f5ba051bb78d6c8f21f2bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Chirico=20Indreb=C3=B8?= Date: Wed, 19 Jul 2023 12:25:04 +0200 Subject: [PATCH 3/4] Add error to frontend models --- frontend/src/language/en.json | 3 ++- frontend/src/language/no.json | 3 ++- frontend/src/models/Inspection.ts | 1 + frontend/src/models/Mission.ts | 1 + frontend/src/models/Task.ts | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/language/en.json b/frontend/src/language/en.json index 731b30ae1..50670c3a2 100644 --- a/frontend/src/language/en.json +++ b/frontend/src/language/en.json @@ -107,5 +107,6 @@ "selected": "selected", "This button is disabled because the robot is not available. Check that the robot is on, and are not doing any other activities.": "This button is disabled because the robot is not available. Check that the robot is on, and are not doing any other activities.", "Close": "Close", - "Localizing": "Localizing" + "Localizing": "Localizing", + "N": "N" } diff --git a/frontend/src/language/no.json b/frontend/src/language/no.json index 77accb8a4..dfc4c86bc 100644 --- a/frontend/src/language/no.json +++ b/frontend/src/language/no.json @@ -107,5 +107,6 @@ "selected": "valgte", "This button is disabled because the robot is not available. Check that the robot is on, and are not doing any other activities.": "Denne knappen er deaktivert fordi roboten ikke er tilgjengelig. Sjekk at roboten er på og ikke gjør noen andre aktiviteter.", "Close": "Steng", - "Localizing": "Lokaliserer" + "Localizing": "Lokaliserer", + "N": "N" } diff --git a/frontend/src/models/Inspection.ts b/frontend/src/models/Inspection.ts index b48951ef9..3c32a1cd9 100644 --- a/frontend/src/models/Inspection.ts +++ b/frontend/src/models/Inspection.ts @@ -9,6 +9,7 @@ export interface Inspection { inspectionUrl?: string startTime?: Date endTime?: Date + error?: string } enum InspectionStatus { diff --git a/frontend/src/models/Mission.ts b/frontend/src/models/Mission.ts index 83e10fd3c..2723b259c 100644 --- a/frontend/src/models/Mission.ts +++ b/frontend/src/models/Mission.ts @@ -31,4 +31,5 @@ export interface Mission { estimatedDuration?: number tasks: Task[] mapMetadata?: MapMetadata + error?: string } diff --git a/frontend/src/models/Task.ts b/frontend/src/models/Task.ts index 659918d10..c5cd7e552 100644 --- a/frontend/src/models/Task.ts +++ b/frontend/src/models/Task.ts @@ -16,6 +16,7 @@ export interface Task { isCompleted: boolean startTime?: Date endTime?: Date + error?: string inspections: Inspection[] } From 1d5e52250e439ad41031cb298a736978e60cf428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Chirico=20Indreb=C3=B8?= Date: Thu, 27 Jul 2023 15:52:57 +0200 Subject: [PATCH 4/4] Add migrations --- ...5_AddErrorReasonAndDescription.Designer.cs | 1153 ++++++++++ ...0727135235_AddErrorReasonAndDescription.cs | 1915 +++++++++++++++++ .../FlotillaDbContextModelSnapshot.cs | 84 +- 3 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 backend/api/Migrations/20230727135235_AddErrorReasonAndDescription.Designer.cs create mode 100644 backend/api/Migrations/20230727135235_AddErrorReasonAndDescription.cs diff --git a/backend/api/Migrations/20230727135235_AddErrorReasonAndDescription.Designer.cs b/backend/api/Migrations/20230727135235_AddErrorReasonAndDescription.Designer.cs new file mode 100644 index 000000000..f2df25dc8 --- /dev/null +++ b/backend/api/Migrations/20230727135235_AddErrorReasonAndDescription.Designer.cs @@ -0,0 +1,1153 @@ +// +using System; +using Api.Database.Context; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Api.Migrations +{ + [DbContext(typeof(FlotillaDbContext))] + [Migration("20230727135235_AddErrorReasonAndDescription")] + partial class AddErrorReasonAndDescription + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Api.Database.Models.Area", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("DeckId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("InstallationId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("PlantId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("DeckId"); + + b.HasIndex("InstallationId"); + + b.HasIndex("PlantId"); + + b.ToTable("Areas"); + }); + + modelBuilder.Entity("Api.Database.Models.AssetDeck", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AssetCode") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("DeckName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.ToTable("AssetDecks"); + }); + + modelBuilder.Entity("Api.Database.Models.Deck", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("InstallationId") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("PlantId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("InstallationId"); + + b.HasIndex("PlantId"); + + b.ToTable("Decks"); + }); + + modelBuilder.Entity("Api.Database.Models.Installation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("InstallationCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("InstallationCode") + .IsUnique(); + + b.ToTable("Installations"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AreaId") + .HasColumnType("nvarchar(450)"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("InspectionFrequency") + .HasColumnType("time"); + + b.Property("InstallationCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeprecated") + .HasColumnType("bit"); + + b.Property("LastRunId") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("SourceId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("AreaId"); + + b.HasIndex("LastRunId"); + + b.HasIndex("SourceId"); + + b.ToTable("MissionDefinitions"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AreaId") + .HasColumnType("nvarchar(450)"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.Property("DesiredStartTime") + .HasColumnType("datetimeoffset"); + + b.Property("EndTime") + .HasColumnType("datetimeoffset"); + + b.Property("ErrorDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorReason") + .HasColumnType("nvarchar(max)"); + + b.Property("EstimatedDuration") + .HasColumnType("bigint"); + + b.Property("InstallationCode") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("IsarMissionId") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("MissionId") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("RobotId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("StartTime") + .HasColumnType("datetimeoffset"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StatusReason") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("AreaId"); + + b.HasIndex("RobotId"); + + b.ToTable("MissionRuns"); + }); + + modelBuilder.Entity("Api.Database.Models.Plant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("InstallationId") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("PlantCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.HasIndex("InstallationId"); + + b.HasIndex("PlantCode") + .IsUnique(); + + b.ToTable("Plants"); + }); + + modelBuilder.Entity("Api.Database.Models.Robot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("BatteryLevel") + .HasColumnType("real"); + + b.Property("CurrentAreaId") + .HasColumnType("nvarchar(450)"); + + b.Property("CurrentInstallation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CurrentMissionId") + .HasColumnType("nvarchar(max)"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("Host") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("IsarId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ModelId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Port") + .HasColumnType("int"); + + b.Property("PressureLevel") + .HasColumnType("real"); + + b.Property("SerialNumber") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CurrentAreaId"); + + b.HasIndex("ModelId"); + + b.ToTable("Robots"); + }); + + modelBuilder.Entity("Api.Database.Models.RobotModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AverageDurationPerTag") + .HasColumnType("real"); + + b.Property("BatteryWarningThreshold") + .HasColumnType("real"); + + b.Property("LowerPressureWarningThreshold") + .HasColumnType("real"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(56)"); + + b.Property("UpperPressureWarningThreshold") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("Type") + .IsUnique(); + + b.ToTable("RobotModels"); + }); + + modelBuilder.Entity("Api.Database.Models.SafePosition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AreaId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("AreaId"); + + b.ToTable("SafePositions"); + }); + + modelBuilder.Entity("Api.Database.Models.Source", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("SourceId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Sources"); + }); + + modelBuilder.Entity("Api.Database.Models.Area", b => + { + b.HasOne("Api.Database.Models.Deck", "Deck") + .WithMany() + .HasForeignKey("DeckId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Api.Database.Models.Installation", "Installation") + .WithMany() + .HasForeignKey("InstallationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Api.Database.Models.Plant", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.OwnsOne("Api.Database.Models.Pose", "DefaultLocalizationPose", b1 => + { + b1.Property("AreaId") + .HasColumnType("nvarchar(450)"); + + b1.HasKey("AreaId"); + + b1.ToTable("Areas"); + + b1.WithOwner() + .HasForeignKey("AreaId"); + + b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + { + b2.Property("PoseAreaId") + .HasColumnType("nvarchar(450)"); + + b2.Property("W") + .HasColumnType("real"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseAreaId"); + + b2.ToTable("Areas"); + + b2.WithOwner() + .HasForeignKey("PoseAreaId"); + }); + + b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => + { + b2.Property("PoseAreaId") + .HasColumnType("nvarchar(450)"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseAreaId"); + + b2.ToTable("Areas"); + + b2.WithOwner() + .HasForeignKey("PoseAreaId"); + }); + + b1.Navigation("Orientation") + .IsRequired(); + + b1.Navigation("Position") + .IsRequired(); + }); + + b.OwnsOne("Api.Database.Models.MapMetadata", "MapMetadata", b1 => + { + b1.Property("AreaId") + .HasColumnType("nvarchar(450)"); + + b1.Property("MapName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b1.HasKey("AreaId"); + + b1.ToTable("Areas"); + + b1.WithOwner() + .HasForeignKey("AreaId"); + + b1.OwnsOne("Api.Database.Models.Boundary", "Boundary", b2 => + { + b2.Property("MapMetadataAreaId") + .HasColumnType("nvarchar(450)"); + + b2.Property("X1") + .HasColumnType("float"); + + b2.Property("X2") + .HasColumnType("float"); + + b2.Property("Y1") + .HasColumnType("float"); + + b2.Property("Y2") + .HasColumnType("float"); + + b2.Property("Z1") + .HasColumnType("float"); + + b2.Property("Z2") + .HasColumnType("float"); + + b2.HasKey("MapMetadataAreaId"); + + b2.ToTable("Areas"); + + b2.WithOwner() + .HasForeignKey("MapMetadataAreaId"); + }); + + b1.OwnsOne("Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => + { + b2.Property("MapMetadataAreaId") + .HasColumnType("nvarchar(450)"); + + b2.Property("C1") + .HasColumnType("float"); + + b2.Property("C2") + .HasColumnType("float"); + + b2.Property("D1") + .HasColumnType("float"); + + b2.Property("D2") + .HasColumnType("float"); + + b2.HasKey("MapMetadataAreaId"); + + b2.ToTable("Areas"); + + b2.WithOwner() + .HasForeignKey("MapMetadataAreaId"); + }); + + b1.Navigation("Boundary") + .IsRequired(); + + b1.Navigation("TransformationMatrices") + .IsRequired(); + }); + + b.Navigation("Deck"); + + b.Navigation("DefaultLocalizationPose") + .IsRequired(); + + b.Navigation("Installation"); + + b.Navigation("MapMetadata") + .IsRequired(); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("Api.Database.Models.Deck", b => + { + b.HasOne("Api.Database.Models.Installation", "Installation") + .WithMany() + .HasForeignKey("InstallationId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Api.Database.Models.Plant", "Plant") + .WithMany() + .HasForeignKey("PlantId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Installation"); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionDefinition", b => + { + b.HasOne("Api.Database.Models.Area", "Area") + .WithMany() + .HasForeignKey("AreaId"); + + b.HasOne("Api.Database.Models.MissionRun", "LastRun") + .WithMany() + .HasForeignKey("LastRunId"); + + b.HasOne("Api.Database.Models.Source", "Source") + .WithMany() + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Area"); + + b.Navigation("LastRun"); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionRun", b => + { + b.HasOne("Api.Database.Models.Area", "Area") + .WithMany() + .HasForeignKey("AreaId"); + + b.HasOne("Api.Database.Models.Robot", "Robot") + .WithMany() + .HasForeignKey("RobotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Api.Database.Models.MapMetadata", "MapMetadata", b1 => + { + b1.Property("MissionRunId") + .HasColumnType("nvarchar(450)"); + + b1.Property("MapName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b1.HasKey("MissionRunId"); + + b1.ToTable("MissionRuns"); + + b1.WithOwner() + .HasForeignKey("MissionRunId"); + + b1.OwnsOne("Api.Database.Models.Boundary", "Boundary", b2 => + { + b2.Property("MapMetadataMissionRunId") + .HasColumnType("nvarchar(450)"); + + b2.Property("X1") + .HasColumnType("float"); + + b2.Property("X2") + .HasColumnType("float"); + + b2.Property("Y1") + .HasColumnType("float"); + + b2.Property("Y2") + .HasColumnType("float"); + + b2.Property("Z1") + .HasColumnType("float"); + + b2.Property("Z2") + .HasColumnType("float"); + + b2.HasKey("MapMetadataMissionRunId"); + + b2.ToTable("MissionRuns"); + + b2.WithOwner() + .HasForeignKey("MapMetadataMissionRunId"); + }); + + b1.OwnsOne("Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => + { + b2.Property("MapMetadataMissionRunId") + .HasColumnType("nvarchar(450)"); + + b2.Property("C1") + .HasColumnType("float"); + + b2.Property("C2") + .HasColumnType("float"); + + b2.Property("D1") + .HasColumnType("float"); + + b2.Property("D2") + .HasColumnType("float"); + + b2.HasKey("MapMetadataMissionRunId"); + + b2.ToTable("MissionRuns"); + + b2.WithOwner() + .HasForeignKey("MapMetadataMissionRunId"); + }); + + b1.Navigation("Boundary") + .IsRequired(); + + b1.Navigation("TransformationMatrices") + .IsRequired(); + }); + + b.OwnsMany("Api.Database.Models.MissionTask", "Tasks", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b1.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b1.Property("EchoPoseId") + .HasColumnType("int"); + + b1.Property("EchoTagLink") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b1.Property("EndTime") + .HasColumnType("datetimeoffset"); + + b1.Property("ErrorDescription") + .HasColumnType("nvarchar(max)"); + + b1.Property("ErrorReason") + .HasColumnType("nvarchar(max)"); + + b1.Property("IsarTaskId") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b1.Property("MissionRunId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b1.Property("StartTime") + .HasColumnType("datetimeoffset"); + + b1.Property("Status") + .HasColumnType("int"); + + b1.Property("TagId") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b1.Property("TaskOrder") + .HasColumnType("int"); + + b1.HasKey("Id"); + + b1.HasIndex("MissionRunId"); + + b1.ToTable("MissionTask"); + + b1.WithOwner() + .HasForeignKey("MissionRunId"); + + b1.OwnsMany("Api.Database.Models.Inspection", "Inspections", b2 => + { + b2.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b2.Property("AnalysisTypes") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b2.Property("EndTime") + .HasColumnType("datetimeoffset"); + + b2.Property("ErrorDescription") + .HasColumnType("nvarchar(max)"); + + b2.Property("ErrorReason") + .HasColumnType("nvarchar(max)"); + + b2.Property("InspectionType") + .HasColumnType("int"); + + b2.Property("InspectionUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b2.Property("IsarStepId") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b2.Property("MissionTaskId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b2.Property("StartTime") + .HasColumnType("datetimeoffset"); + + b2.Property("Status") + .HasColumnType("int"); + + b2.Property("VideoDuration") + .HasColumnType("real"); + + b2.HasKey("Id"); + + b2.HasIndex("MissionTaskId"); + + b2.ToTable("Inspection"); + + b2.WithOwner() + .HasForeignKey("MissionTaskId"); + }); + + b1.OwnsOne("Api.Database.Models.Position", "InspectionTarget", b2 => + { + b2.Property("MissionTaskId") + .HasColumnType("nvarchar(450)"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("MissionTaskId"); + + b2.ToTable("MissionTask"); + + b2.WithOwner() + .HasForeignKey("MissionTaskId"); + }); + + b1.OwnsOne("Api.Database.Models.Pose", "RobotPose", b2 => + { + b2.Property("MissionTaskId") + .HasColumnType("nvarchar(450)"); + + b2.HasKey("MissionTaskId"); + + b2.ToTable("MissionTask"); + + b2.WithOwner() + .HasForeignKey("MissionTaskId"); + + b2.OwnsOne("Api.Database.Models.Orientation", "Orientation", b3 => + { + b3.Property("PoseMissionTaskId") + .HasColumnType("nvarchar(450)"); + + b3.Property("W") + .HasColumnType("real"); + + b3.Property("X") + .HasColumnType("real"); + + b3.Property("Y") + .HasColumnType("real"); + + b3.Property("Z") + .HasColumnType("real"); + + b3.HasKey("PoseMissionTaskId"); + + b3.ToTable("MissionTask"); + + b3.WithOwner() + .HasForeignKey("PoseMissionTaskId"); + }); + + b2.OwnsOne("Api.Database.Models.Position", "Position", b3 => + { + b3.Property("PoseMissionTaskId") + .HasColumnType("nvarchar(450)"); + + b3.Property("X") + .HasColumnType("real"); + + b3.Property("Y") + .HasColumnType("real"); + + b3.Property("Z") + .HasColumnType("real"); + + b3.HasKey("PoseMissionTaskId"); + + b3.ToTable("MissionTask"); + + b3.WithOwner() + .HasForeignKey("PoseMissionTaskId"); + }); + + b2.Navigation("Orientation") + .IsRequired(); + + b2.Navigation("Position") + .IsRequired(); + }); + + b1.Navigation("InspectionTarget") + .IsRequired(); + + b1.Navigation("Inspections"); + + b1.Navigation("RobotPose") + .IsRequired(); + }); + + b.Navigation("Area"); + + b.Navigation("MapMetadata"); + + b.Navigation("Robot"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("Api.Database.Models.Plant", b => + { + b.HasOne("Api.Database.Models.Installation", "Installation") + .WithMany() + .HasForeignKey("InstallationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Installation"); + }); + + modelBuilder.Entity("Api.Database.Models.Robot", b => + { + b.HasOne("Api.Database.Models.Area", "CurrentArea") + .WithMany() + .HasForeignKey("CurrentAreaId"); + + b.HasOne("Api.Database.Models.RobotModel", "Model") + .WithMany() + .HasForeignKey("ModelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => + { + b1.Property("RobotId") + .HasColumnType("nvarchar(450)"); + + b1.HasKey("RobotId"); + + b1.ToTable("Robots"); + + b1.WithOwner() + .HasForeignKey("RobotId"); + + b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + { + b2.Property("PoseRobotId") + .HasColumnType("nvarchar(450)"); + + b2.Property("W") + .HasColumnType("real"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseRobotId"); + + b2.ToTable("Robots"); + + b2.WithOwner() + .HasForeignKey("PoseRobotId"); + }); + + b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => + { + b2.Property("PoseRobotId") + .HasColumnType("nvarchar(450)"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseRobotId"); + + b2.ToTable("Robots"); + + b2.WithOwner() + .HasForeignKey("PoseRobotId"); + }); + + b1.Navigation("Orientation") + .IsRequired(); + + b1.Navigation("Position") + .IsRequired(); + }); + + b.OwnsMany("Api.Database.Models.VideoStream", "VideoStreams", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b1.Property("RobotId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b1.Property("ShouldRotate270Clockwise") + .HasColumnType("bit"); + + b1.Property("Type") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b1.Property("Url") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b1.HasKey("Id"); + + b1.HasIndex("RobotId"); + + b1.ToTable("VideoStream"); + + b1.WithOwner() + .HasForeignKey("RobotId"); + }); + + b.Navigation("CurrentArea"); + + b.Navigation("Model"); + + b.Navigation("Pose") + .IsRequired(); + + b.Navigation("VideoStreams"); + }); + + modelBuilder.Entity("Api.Database.Models.SafePosition", b => + { + b.HasOne("Api.Database.Models.Area", null) + .WithMany("SafePositions") + .HasForeignKey("AreaId"); + + b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => + { + b1.Property("SafePositionId") + .HasColumnType("nvarchar(450)"); + + b1.HasKey("SafePositionId"); + + b1.ToTable("SafePositions"); + + b1.WithOwner() + .HasForeignKey("SafePositionId"); + + b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + { + b2.Property("PoseSafePositionId") + .HasColumnType("nvarchar(450)"); + + b2.Property("W") + .HasColumnType("real"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseSafePositionId"); + + b2.ToTable("SafePositions"); + + b2.WithOwner() + .HasForeignKey("PoseSafePositionId"); + }); + + b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => + { + b2.Property("PoseSafePositionId") + .HasColumnType("nvarchar(450)"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseSafePositionId"); + + b2.ToTable("SafePositions"); + + b2.WithOwner() + .HasForeignKey("PoseSafePositionId"); + }); + + b1.Navigation("Orientation") + .IsRequired(); + + b1.Navigation("Position") + .IsRequired(); + }); + + b.Navigation("Pose") + .IsRequired(); + }); + + modelBuilder.Entity("Api.Database.Models.Area", b => + { + b.Navigation("SafePositions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/backend/api/Migrations/20230727135235_AddErrorReasonAndDescription.cs b/backend/api/Migrations/20230727135235_AddErrorReasonAndDescription.cs new file mode 100644 index 000000000..d9e19ced1 --- /dev/null +++ b/backend/api/Migrations/20230727135235_AddErrorReasonAndDescription.cs @@ -0,0 +1,1915 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Api.Migrations +{ + /// + public partial class AddErrorReasonAndDescription : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Area_Deck_DeckId", + table: "Area"); + + migrationBuilder.DropForeignKey( + name: "FK_Area_Installation_InstallationId", + table: "Area"); + + migrationBuilder.DropForeignKey( + name: "FK_Area_Plant_PlantId", + table: "Area"); + + migrationBuilder.DropForeignKey( + name: "FK_Deck_Installation_InstallationId", + table: "Deck"); + + migrationBuilder.DropForeignKey( + name: "FK_Deck_Plant_PlantId", + table: "Deck"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionDefinition_Area_AreaId", + table: "MissionDefinition"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionDefinition_MissionRun_LastRunId", + table: "MissionDefinition"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionDefinition_Source_SourceId", + table: "MissionDefinition"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionRun_Area_AreaId", + table: "MissionRun"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionRun_Robot_RobotId", + table: "MissionRun"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionTask_MissionRun_MissionRunId", + table: "MissionTask"); + + migrationBuilder.DropForeignKey( + name: "FK_Plant_Installation_InstallationId", + table: "Plant"); + + migrationBuilder.DropForeignKey( + name: "FK_Robot_Area_CurrentAreaId", + table: "Robot"); + + migrationBuilder.DropForeignKey( + name: "FK_Robot_RobotModel_ModelId", + table: "Robot"); + + migrationBuilder.DropForeignKey( + name: "FK_SafePosition_Area_AreaId", + table: "SafePosition"); + + migrationBuilder.DropForeignKey( + name: "FK_VideoStream_Robot_RobotId", + table: "VideoStream"); + + migrationBuilder.DropTable( + name: "Area.DefaultLocalizationPose#Pose.Orientation#Orientation"); + + migrationBuilder.DropTable( + name: "Area.DefaultLocalizationPose#Pose.Position#Position"); + + migrationBuilder.DropTable( + name: "Area.MapMetadata#MapMetadata.Boundary#Boundary"); + + migrationBuilder.DropTable( + name: "Area.MapMetadata#MapMetadata.TransformationMatrices#TransformationMatrices"); + + migrationBuilder.DropTable( + name: "MissionRun.MapMetadata#MapMetadata.Boundary#Boundary"); + + migrationBuilder.DropTable( + name: "MissionRun.MapMetadata#MapMetadata.TransformationMatrices#TransformationMatrices"); + + migrationBuilder.DropTable( + name: "MissionTask.InspectionTarget#Position"); + + migrationBuilder.DropTable( + name: "MissionTask.RobotPose#Pose.Orientation#Orientation"); + + migrationBuilder.DropTable( + name: "MissionTask.RobotPose#Pose.Position#Position"); + + migrationBuilder.DropTable( + name: "Robot.Pose#Pose.Orientation#Orientation"); + + migrationBuilder.DropTable( + name: "Robot.Pose#Pose.Position#Position"); + + migrationBuilder.DropTable( + name: "SafePosition.Pose#Pose.Orientation#Orientation"); + + migrationBuilder.DropTable( + name: "SafePosition.Pose#Pose.Position#Position"); + + migrationBuilder.DropTable( + name: "Area.DefaultLocalizationPose#Pose"); + + migrationBuilder.DropTable( + name: "Area.MapMetadata#MapMetadata"); + + migrationBuilder.DropTable( + name: "MissionRun.MapMetadata#MapMetadata"); + + migrationBuilder.DropTable( + name: "MissionTask.RobotPose#Pose"); + + migrationBuilder.DropTable( + name: "Robot.Pose#Pose"); + + migrationBuilder.DropTable( + name: "SafePosition.Pose#Pose"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Source", + table: "Source"); + + migrationBuilder.DropPrimaryKey( + name: "PK_SafePosition", + table: "SafePosition"); + + migrationBuilder.DropPrimaryKey( + name: "PK_RobotModel", + table: "RobotModel"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Robot", + table: "Robot"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Plant", + table: "Plant"); + + migrationBuilder.DropPrimaryKey( + name: "PK_MissionRun", + table: "MissionRun"); + + migrationBuilder.DropPrimaryKey( + name: "PK_MissionDefinition", + table: "MissionDefinition"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Installation", + table: "Installation"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Deck", + table: "Deck"); + + migrationBuilder.DropPrimaryKey( + name: "PK_AssetDeck", + table: "AssetDeck"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Area", + table: "Area"); + + migrationBuilder.RenameTable( + name: "Source", + newName: "Sources"); + + migrationBuilder.RenameTable( + name: "SafePosition", + newName: "SafePositions"); + + migrationBuilder.RenameTable( + name: "RobotModel", + newName: "RobotModels"); + + migrationBuilder.RenameTable( + name: "Robot", + newName: "Robots"); + + migrationBuilder.RenameTable( + name: "Plant", + newName: "Plants"); + + migrationBuilder.RenameTable( + name: "MissionRun", + newName: "MissionRuns"); + + migrationBuilder.RenameTable( + name: "MissionDefinition", + newName: "MissionDefinitions"); + + migrationBuilder.RenameTable( + name: "Installation", + newName: "Installations"); + + migrationBuilder.RenameTable( + name: "Deck", + newName: "Decks"); + + migrationBuilder.RenameTable( + name: "AssetDeck", + newName: "AssetDecks"); + + migrationBuilder.RenameTable( + name: "Area", + newName: "Areas"); + + migrationBuilder.RenameIndex( + name: "IX_SafePosition_AreaId", + table: "SafePositions", + newName: "IX_SafePositions_AreaId"); + + migrationBuilder.RenameIndex( + name: "IX_RobotModel_Type", + table: "RobotModels", + newName: "IX_RobotModels_Type"); + + migrationBuilder.RenameIndex( + name: "IX_Robot_ModelId", + table: "Robots", + newName: "IX_Robots_ModelId"); + + migrationBuilder.RenameIndex( + name: "IX_Robot_CurrentAreaId", + table: "Robots", + newName: "IX_Robots_CurrentAreaId"); + + migrationBuilder.RenameIndex( + name: "IX_Plant_PlantCode", + table: "Plants", + newName: "IX_Plants_PlantCode"); + + migrationBuilder.RenameIndex( + name: "IX_Plant_InstallationId", + table: "Plants", + newName: "IX_Plants_InstallationId"); + + migrationBuilder.RenameIndex( + name: "IX_MissionRun_RobotId", + table: "MissionRuns", + newName: "IX_MissionRuns_RobotId"); + + migrationBuilder.RenameIndex( + name: "IX_MissionRun_AreaId", + table: "MissionRuns", + newName: "IX_MissionRuns_AreaId"); + + migrationBuilder.RenameIndex( + name: "IX_MissionDefinition_SourceId", + table: "MissionDefinitions", + newName: "IX_MissionDefinitions_SourceId"); + + migrationBuilder.RenameIndex( + name: "IX_MissionDefinition_LastRunId", + table: "MissionDefinitions", + newName: "IX_MissionDefinitions_LastRunId"); + + migrationBuilder.RenameIndex( + name: "IX_MissionDefinition_AreaId", + table: "MissionDefinitions", + newName: "IX_MissionDefinitions_AreaId"); + + migrationBuilder.RenameIndex( + name: "IX_Installation_InstallationCode", + table: "Installations", + newName: "IX_Installations_InstallationCode"); + + migrationBuilder.RenameIndex( + name: "IX_Deck_PlantId", + table: "Decks", + newName: "IX_Decks_PlantId"); + + migrationBuilder.RenameIndex( + name: "IX_Deck_InstallationId", + table: "Decks", + newName: "IX_Decks_InstallationId"); + + migrationBuilder.RenameIndex( + name: "IX_Area_PlantId", + table: "Areas", + newName: "IX_Areas_PlantId"); + + migrationBuilder.RenameIndex( + name: "IX_Area_InstallationId", + table: "Areas", + newName: "IX_Areas_InstallationId"); + + migrationBuilder.RenameIndex( + name: "IX_Area_DeckId", + table: "Areas", + newName: "IX_Areas_DeckId"); + + migrationBuilder.AddColumn( + name: "ErrorDescription", + table: "MissionTask", + type: "nvarchar(max)", + nullable: true); + + migrationBuilder.AddColumn( + name: "ErrorReason", + table: "MissionTask", + type: "nvarchar(max)", + nullable: true); + + migrationBuilder.AddColumn( + name: "InspectionTarget_X", + table: "MissionTask", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "InspectionTarget_Y", + table: "MissionTask", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "InspectionTarget_Z", + table: "MissionTask", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "RobotPose_Orientation_W", + table: "MissionTask", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "RobotPose_Orientation_X", + table: "MissionTask", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "RobotPose_Orientation_Y", + table: "MissionTask", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "RobotPose_Orientation_Z", + table: "MissionTask", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "RobotPose_Position_X", + table: "MissionTask", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "RobotPose_Position_Y", + table: "MissionTask", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "RobotPose_Position_Z", + table: "MissionTask", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "ErrorDescription", + table: "Inspection", + type: "nvarchar(max)", + nullable: true); + + migrationBuilder.AddColumn( + name: "ErrorReason", + table: "Inspection", + type: "nvarchar(max)", + nullable: true); + + migrationBuilder.AddColumn( + name: "Pose_Orientation_W", + table: "SafePositions", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Orientation_X", + table: "SafePositions", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Orientation_Y", + table: "SafePositions", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Orientation_Z", + table: "SafePositions", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Position_X", + table: "SafePositions", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Position_Y", + table: "SafePositions", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Position_Z", + table: "SafePositions", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Orientation_W", + table: "Robots", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Orientation_X", + table: "Robots", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Orientation_Y", + table: "Robots", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Orientation_Z", + table: "Robots", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Position_X", + table: "Robots", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Position_Y", + table: "Robots", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "Pose_Position_Z", + table: "Robots", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "ErrorDescription", + table: "MissionRuns", + type: "nvarchar(max)", + nullable: true); + + migrationBuilder.AddColumn( + name: "ErrorReason", + table: "MissionRuns", + type: "nvarchar(max)", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_X1", + table: "MissionRuns", + type: "float", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_X2", + table: "MissionRuns", + type: "float", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_Y1", + table: "MissionRuns", + type: "float", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_Y2", + table: "MissionRuns", + type: "float", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_Z1", + table: "MissionRuns", + type: "float", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_Z2", + table: "MissionRuns", + type: "float", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapMetadata_MapName", + table: "MissionRuns", + type: "nvarchar(200)", + maxLength: 200, + nullable: true); + + migrationBuilder.AddColumn( + name: "MapMetadata_TransformationMatrices_C1", + table: "MissionRuns", + type: "float", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapMetadata_TransformationMatrices_C2", + table: "MissionRuns", + type: "float", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapMetadata_TransformationMatrices_D1", + table: "MissionRuns", + type: "float", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapMetadata_TransformationMatrices_D2", + table: "MissionRuns", + type: "float", + nullable: true); + + migrationBuilder.AddColumn( + name: "DefaultLocalizationPose_Orientation_W", + table: "Areas", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "DefaultLocalizationPose_Orientation_X", + table: "Areas", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "DefaultLocalizationPose_Orientation_Y", + table: "Areas", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "DefaultLocalizationPose_Orientation_Z", + table: "Areas", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "DefaultLocalizationPose_Position_X", + table: "Areas", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "DefaultLocalizationPose_Position_Y", + table: "Areas", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "DefaultLocalizationPose_Position_Z", + table: "Areas", + type: "real", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_X1", + table: "Areas", + type: "float", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_X2", + table: "Areas", + type: "float", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_Y1", + table: "Areas", + type: "float", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_Y2", + table: "Areas", + type: "float", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_Z1", + table: "Areas", + type: "float", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "MapMetadata_Boundary_Z2", + table: "Areas", + type: "float", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "MapMetadata_MapName", + table: "Areas", + type: "nvarchar(200)", + maxLength: 200, + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "MapMetadata_TransformationMatrices_C1", + table: "Areas", + type: "float", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "MapMetadata_TransformationMatrices_C2", + table: "Areas", + type: "float", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "MapMetadata_TransformationMatrices_D1", + table: "Areas", + type: "float", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddColumn( + name: "MapMetadata_TransformationMatrices_D2", + table: "Areas", + type: "float", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AddPrimaryKey( + name: "PK_Sources", + table: "Sources", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_SafePositions", + table: "SafePositions", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_RobotModels", + table: "RobotModels", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Robots", + table: "Robots", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Plants", + table: "Plants", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_MissionRuns", + table: "MissionRuns", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_MissionDefinitions", + table: "MissionDefinitions", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Installations", + table: "Installations", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Decks", + table: "Decks", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_AssetDecks", + table: "AssetDecks", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Areas", + table: "Areas", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Areas_Decks_DeckId", + table: "Areas", + column: "DeckId", + principalTable: "Decks", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Areas_Installations_InstallationId", + table: "Areas", + column: "InstallationId", + principalTable: "Installations", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Areas_Plants_PlantId", + table: "Areas", + column: "PlantId", + principalTable: "Plants", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Decks_Installations_InstallationId", + table: "Decks", + column: "InstallationId", + principalTable: "Installations", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Decks_Plants_PlantId", + table: "Decks", + column: "PlantId", + principalTable: "Plants", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MissionDefinitions_Areas_AreaId", + table: "MissionDefinitions", + column: "AreaId", + principalTable: "Areas", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_MissionDefinitions_MissionRuns_LastRunId", + table: "MissionDefinitions", + column: "LastRunId", + principalTable: "MissionRuns", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_MissionDefinitions_Sources_SourceId", + table: "MissionDefinitions", + column: "SourceId", + principalTable: "Sources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_MissionRuns_Areas_AreaId", + table: "MissionRuns", + column: "AreaId", + principalTable: "Areas", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_MissionRuns_Robots_RobotId", + table: "MissionRuns", + column: "RobotId", + principalTable: "Robots", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_MissionTask_MissionRuns_MissionRunId", + table: "MissionTask", + column: "MissionRunId", + principalTable: "MissionRuns", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Plants_Installations_InstallationId", + table: "Plants", + column: "InstallationId", + principalTable: "Installations", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Robots_Areas_CurrentAreaId", + table: "Robots", + column: "CurrentAreaId", + principalTable: "Areas", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Robots_RobotModels_ModelId", + table: "Robots", + column: "ModelId", + principalTable: "RobotModels", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_SafePositions_Areas_AreaId", + table: "SafePositions", + column: "AreaId", + principalTable: "Areas", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_VideoStream_Robots_RobotId", + table: "VideoStream", + column: "RobotId", + principalTable: "Robots", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Areas_Decks_DeckId", + table: "Areas"); + + migrationBuilder.DropForeignKey( + name: "FK_Areas_Installations_InstallationId", + table: "Areas"); + + migrationBuilder.DropForeignKey( + name: "FK_Areas_Plants_PlantId", + table: "Areas"); + + migrationBuilder.DropForeignKey( + name: "FK_Decks_Installations_InstallationId", + table: "Decks"); + + migrationBuilder.DropForeignKey( + name: "FK_Decks_Plants_PlantId", + table: "Decks"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionDefinitions_Areas_AreaId", + table: "MissionDefinitions"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionDefinitions_MissionRuns_LastRunId", + table: "MissionDefinitions"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionDefinitions_Sources_SourceId", + table: "MissionDefinitions"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionRuns_Areas_AreaId", + table: "MissionRuns"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionRuns_Robots_RobotId", + table: "MissionRuns"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionTask_MissionRuns_MissionRunId", + table: "MissionTask"); + + migrationBuilder.DropForeignKey( + name: "FK_Plants_Installations_InstallationId", + table: "Plants"); + + migrationBuilder.DropForeignKey( + name: "FK_Robots_Areas_CurrentAreaId", + table: "Robots"); + + migrationBuilder.DropForeignKey( + name: "FK_Robots_RobotModels_ModelId", + table: "Robots"); + + migrationBuilder.DropForeignKey( + name: "FK_SafePositions_Areas_AreaId", + table: "SafePositions"); + + migrationBuilder.DropForeignKey( + name: "FK_VideoStream_Robots_RobotId", + table: "VideoStream"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Sources", + table: "Sources"); + + migrationBuilder.DropPrimaryKey( + name: "PK_SafePositions", + table: "SafePositions"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Robots", + table: "Robots"); + + migrationBuilder.DropPrimaryKey( + name: "PK_RobotModels", + table: "RobotModels"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Plants", + table: "Plants"); + + migrationBuilder.DropPrimaryKey( + name: "PK_MissionRuns", + table: "MissionRuns"); + + migrationBuilder.DropPrimaryKey( + name: "PK_MissionDefinitions", + table: "MissionDefinitions"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Installations", + table: "Installations"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Decks", + table: "Decks"); + + migrationBuilder.DropPrimaryKey( + name: "PK_AssetDecks", + table: "AssetDecks"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Areas", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "ErrorDescription", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "ErrorReason", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "InspectionTarget_X", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "InspectionTarget_Y", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "InspectionTarget_Z", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "RobotPose_Orientation_W", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "RobotPose_Orientation_X", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "RobotPose_Orientation_Y", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "RobotPose_Orientation_Z", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "RobotPose_Position_X", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "RobotPose_Position_Y", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "RobotPose_Position_Z", + table: "MissionTask"); + + migrationBuilder.DropColumn( + name: "ErrorDescription", + table: "Inspection"); + + migrationBuilder.DropColumn( + name: "ErrorReason", + table: "Inspection"); + + migrationBuilder.DropColumn( + name: "Pose_Orientation_W", + table: "SafePositions"); + + migrationBuilder.DropColumn( + name: "Pose_Orientation_X", + table: "SafePositions"); + + migrationBuilder.DropColumn( + name: "Pose_Orientation_Y", + table: "SafePositions"); + + migrationBuilder.DropColumn( + name: "Pose_Orientation_Z", + table: "SafePositions"); + + migrationBuilder.DropColumn( + name: "Pose_Position_X", + table: "SafePositions"); + + migrationBuilder.DropColumn( + name: "Pose_Position_Y", + table: "SafePositions"); + + migrationBuilder.DropColumn( + name: "Pose_Position_Z", + table: "SafePositions"); + + migrationBuilder.DropColumn( + name: "Pose_Orientation_W", + table: "Robots"); + + migrationBuilder.DropColumn( + name: "Pose_Orientation_X", + table: "Robots"); + + migrationBuilder.DropColumn( + name: "Pose_Orientation_Y", + table: "Robots"); + + migrationBuilder.DropColumn( + name: "Pose_Orientation_Z", + table: "Robots"); + + migrationBuilder.DropColumn( + name: "Pose_Position_X", + table: "Robots"); + + migrationBuilder.DropColumn( + name: "Pose_Position_Y", + table: "Robots"); + + migrationBuilder.DropColumn( + name: "Pose_Position_Z", + table: "Robots"); + + migrationBuilder.DropColumn( + name: "ErrorDescription", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "ErrorReason", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_X1", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_X2", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_Y1", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_Y2", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_Z1", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_Z2", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "MapMetadata_MapName", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "MapMetadata_TransformationMatrices_C1", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "MapMetadata_TransformationMatrices_C2", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "MapMetadata_TransformationMatrices_D1", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "MapMetadata_TransformationMatrices_D2", + table: "MissionRuns"); + + migrationBuilder.DropColumn( + name: "DefaultLocalizationPose_Orientation_W", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "DefaultLocalizationPose_Orientation_X", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "DefaultLocalizationPose_Orientation_Y", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "DefaultLocalizationPose_Orientation_Z", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "DefaultLocalizationPose_Position_X", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "DefaultLocalizationPose_Position_Y", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "DefaultLocalizationPose_Position_Z", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_X1", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_X2", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_Y1", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_Y2", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_Z1", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "MapMetadata_Boundary_Z2", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "MapMetadata_MapName", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "MapMetadata_TransformationMatrices_C1", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "MapMetadata_TransformationMatrices_C2", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "MapMetadata_TransformationMatrices_D1", + table: "Areas"); + + migrationBuilder.DropColumn( + name: "MapMetadata_TransformationMatrices_D2", + table: "Areas"); + + migrationBuilder.RenameTable( + name: "Sources", + newName: "Source"); + + migrationBuilder.RenameTable( + name: "SafePositions", + newName: "SafePosition"); + + migrationBuilder.RenameTable( + name: "Robots", + newName: "Robot"); + + migrationBuilder.RenameTable( + name: "RobotModels", + newName: "RobotModel"); + + migrationBuilder.RenameTable( + name: "Plants", + newName: "Plant"); + + migrationBuilder.RenameTable( + name: "MissionRuns", + newName: "MissionRun"); + + migrationBuilder.RenameTable( + name: "MissionDefinitions", + newName: "MissionDefinition"); + + migrationBuilder.RenameTable( + name: "Installations", + newName: "Installation"); + + migrationBuilder.RenameTable( + name: "Decks", + newName: "Deck"); + + migrationBuilder.RenameTable( + name: "AssetDecks", + newName: "AssetDeck"); + + migrationBuilder.RenameTable( + name: "Areas", + newName: "Area"); + + migrationBuilder.RenameIndex( + name: "IX_SafePositions_AreaId", + table: "SafePosition", + newName: "IX_SafePosition_AreaId"); + + migrationBuilder.RenameIndex( + name: "IX_Robots_ModelId", + table: "Robot", + newName: "IX_Robot_ModelId"); + + migrationBuilder.RenameIndex( + name: "IX_Robots_CurrentAreaId", + table: "Robot", + newName: "IX_Robot_CurrentAreaId"); + + migrationBuilder.RenameIndex( + name: "IX_RobotModels_Type", + table: "RobotModel", + newName: "IX_RobotModel_Type"); + + migrationBuilder.RenameIndex( + name: "IX_Plants_PlantCode", + table: "Plant", + newName: "IX_Plant_PlantCode"); + + migrationBuilder.RenameIndex( + name: "IX_Plants_InstallationId", + table: "Plant", + newName: "IX_Plant_InstallationId"); + + migrationBuilder.RenameIndex( + name: "IX_MissionRuns_RobotId", + table: "MissionRun", + newName: "IX_MissionRun_RobotId"); + + migrationBuilder.RenameIndex( + name: "IX_MissionRuns_AreaId", + table: "MissionRun", + newName: "IX_MissionRun_AreaId"); + + migrationBuilder.RenameIndex( + name: "IX_MissionDefinitions_SourceId", + table: "MissionDefinition", + newName: "IX_MissionDefinition_SourceId"); + + migrationBuilder.RenameIndex( + name: "IX_MissionDefinitions_LastRunId", + table: "MissionDefinition", + newName: "IX_MissionDefinition_LastRunId"); + + migrationBuilder.RenameIndex( + name: "IX_MissionDefinitions_AreaId", + table: "MissionDefinition", + newName: "IX_MissionDefinition_AreaId"); + + migrationBuilder.RenameIndex( + name: "IX_Installations_InstallationCode", + table: "Installation", + newName: "IX_Installation_InstallationCode"); + + migrationBuilder.RenameIndex( + name: "IX_Decks_PlantId", + table: "Deck", + newName: "IX_Deck_PlantId"); + + migrationBuilder.RenameIndex( + name: "IX_Decks_InstallationId", + table: "Deck", + newName: "IX_Deck_InstallationId"); + + migrationBuilder.RenameIndex( + name: "IX_Areas_PlantId", + table: "Area", + newName: "IX_Area_PlantId"); + + migrationBuilder.RenameIndex( + name: "IX_Areas_InstallationId", + table: "Area", + newName: "IX_Area_InstallationId"); + + migrationBuilder.RenameIndex( + name: "IX_Areas_DeckId", + table: "Area", + newName: "IX_Area_DeckId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Source", + table: "Source", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_SafePosition", + table: "SafePosition", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Robot", + table: "Robot", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_RobotModel", + table: "RobotModel", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Plant", + table: "Plant", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_MissionRun", + table: "MissionRun", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_MissionDefinition", + table: "MissionDefinition", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Installation", + table: "Installation", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Deck", + table: "Deck", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_AssetDeck", + table: "AssetDeck", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Area", + table: "Area", + column: "Id"); + + migrationBuilder.CreateTable( + name: "Area.DefaultLocalizationPose#Pose", + columns: table => new + { + AreaId = table.Column(type: "nvarchar(450)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Area.DefaultLocalizationPose#Pose", x => x.AreaId); + table.ForeignKey( + name: "FK_Area.DefaultLocalizationPose#Pose_Area_AreaId", + column: x => x.AreaId, + principalTable: "Area", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Area.MapMetadata#MapMetadata", + columns: table => new + { + AreaId = table.Column(type: "nvarchar(450)", nullable: false), + MapName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Area.MapMetadata#MapMetadata", x => x.AreaId); + table.ForeignKey( + name: "FK_Area.MapMetadata#MapMetadata_Area_AreaId", + column: x => x.AreaId, + principalTable: "Area", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MissionRun.MapMetadata#MapMetadata", + columns: table => new + { + MissionRunId = table.Column(type: "nvarchar(450)", nullable: false), + MapName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MissionRun.MapMetadata#MapMetadata", x => x.MissionRunId); + table.ForeignKey( + name: "FK_MissionRun.MapMetadata#MapMetadata_MissionRun_MissionRunId", + column: x => x.MissionRunId, + principalTable: "MissionRun", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MissionTask.InspectionTarget#Position", + columns: table => new + { + MissionTaskId = table.Column(type: "nvarchar(450)", nullable: false), + X = table.Column(type: "real", nullable: false), + Y = table.Column(type: "real", nullable: false), + Z = table.Column(type: "real", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MissionTask.InspectionTarget#Position", x => x.MissionTaskId); + table.ForeignKey( + name: "FK_MissionTask.InspectionTarget#Position_MissionTask_MissionTaskId", + column: x => x.MissionTaskId, + principalTable: "MissionTask", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MissionTask.RobotPose#Pose", + columns: table => new + { + MissionTaskId = table.Column(type: "nvarchar(450)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MissionTask.RobotPose#Pose", x => x.MissionTaskId); + table.ForeignKey( + name: "FK_MissionTask.RobotPose#Pose_MissionTask_MissionTaskId", + column: x => x.MissionTaskId, + principalTable: "MissionTask", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Robot.Pose#Pose", + columns: table => new + { + RobotId = table.Column(type: "nvarchar(450)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Robot.Pose#Pose", x => x.RobotId); + table.ForeignKey( + name: "FK_Robot.Pose#Pose_Robot_RobotId", + column: x => x.RobotId, + principalTable: "Robot", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SafePosition.Pose#Pose", + columns: table => new + { + SafePositionId = table.Column(type: "nvarchar(450)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SafePosition.Pose#Pose", x => x.SafePositionId); + table.ForeignKey( + name: "FK_SafePosition.Pose#Pose_SafePosition_SafePositionId", + column: x => x.SafePositionId, + principalTable: "SafePosition", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Area.DefaultLocalizationPose#Pose.Orientation#Orientation", + columns: table => new + { + PoseAreaId = table.Column(type: "nvarchar(450)", nullable: false), + W = table.Column(type: "real", nullable: false), + X = table.Column(type: "real", nullable: false), + Y = table.Column(type: "real", nullable: false), + Z = table.Column(type: "real", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Area.DefaultLocalizationPose#Pose.Orientation#Orientation", x => x.PoseAreaId); + table.ForeignKey( + name: "FK_Area.DefaultLocalizationPose#Pose.Orientation#Orientation_Area.DefaultLocalizationPose#Pose_PoseAreaId", + column: x => x.PoseAreaId, + principalTable: "Area.DefaultLocalizationPose#Pose", + principalColumn: "AreaId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Area.DefaultLocalizationPose#Pose.Position#Position", + columns: table => new + { + PoseAreaId = table.Column(type: "nvarchar(450)", nullable: false), + X = table.Column(type: "real", nullable: false), + Y = table.Column(type: "real", nullable: false), + Z = table.Column(type: "real", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Area.DefaultLocalizationPose#Pose.Position#Position", x => x.PoseAreaId); + table.ForeignKey( + name: "FK_Area.DefaultLocalizationPose#Pose.Position#Position_Area.DefaultLocalizationPose#Pose_PoseAreaId", + column: x => x.PoseAreaId, + principalTable: "Area.DefaultLocalizationPose#Pose", + principalColumn: "AreaId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Area.MapMetadata#MapMetadata.Boundary#Boundary", + columns: table => new + { + MapMetadataAreaId = table.Column(type: "nvarchar(450)", nullable: false), + X1 = table.Column(type: "float", nullable: false), + X2 = table.Column(type: "float", nullable: false), + Y1 = table.Column(type: "float", nullable: false), + Y2 = table.Column(type: "float", nullable: false), + Z1 = table.Column(type: "float", nullable: false), + Z2 = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Area.MapMetadata#MapMetadata.Boundary#Boundary", x => x.MapMetadataAreaId); + table.ForeignKey( + name: "FK_Area.MapMetadata#MapMetadata.Boundary#Boundary_Area.MapMetadata#MapMetadata_MapMetadataAreaId", + column: x => x.MapMetadataAreaId, + principalTable: "Area.MapMetadata#MapMetadata", + principalColumn: "AreaId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Area.MapMetadata#MapMetadata.TransformationMatrices#TransformationMatrices", + columns: table => new + { + MapMetadataAreaId = table.Column(type: "nvarchar(450)", nullable: false), + C1 = table.Column(type: "float", nullable: false), + C2 = table.Column(type: "float", nullable: false), + D1 = table.Column(type: "float", nullable: false), + D2 = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Area.MapMetadata#MapMetadata.TransformationMatrices#TransformationMatrices", x => x.MapMetadataAreaId); + table.ForeignKey( + name: "FK_Area.MapMetadata#MapMetadata.TransformationMatrices#TransformationMatrices_Area.MapMetadata#MapMetadata_MapMetadataAreaId", + column: x => x.MapMetadataAreaId, + principalTable: "Area.MapMetadata#MapMetadata", + principalColumn: "AreaId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MissionRun.MapMetadata#MapMetadata.Boundary#Boundary", + columns: table => new + { + MapMetadataMissionRunId = table.Column(type: "nvarchar(450)", nullable: false), + X1 = table.Column(type: "float", nullable: false), + X2 = table.Column(type: "float", nullable: false), + Y1 = table.Column(type: "float", nullable: false), + Y2 = table.Column(type: "float", nullable: false), + Z1 = table.Column(type: "float", nullable: false), + Z2 = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MissionRun.MapMetadata#MapMetadata.Boundary#Boundary", x => x.MapMetadataMissionRunId); + table.ForeignKey( + name: "FK_MissionRun.MapMetadata#MapMetadata.Boundary#Boundary_MissionRun.MapMetadata#MapMetadata_MapMetadataMissionRunId", + column: x => x.MapMetadataMissionRunId, + principalTable: "MissionRun.MapMetadata#MapMetadata", + principalColumn: "MissionRunId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MissionRun.MapMetadata#MapMetadata.TransformationMatrices#TransformationMatrices", + columns: table => new + { + MapMetadataMissionRunId = table.Column(type: "nvarchar(450)", nullable: false), + C1 = table.Column(type: "float", nullable: false), + C2 = table.Column(type: "float", nullable: false), + D1 = table.Column(type: "float", nullable: false), + D2 = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MissionRun.MapMetadata#MapMetadata.TransformationMatrices#TransformationMatrices", x => x.MapMetadataMissionRunId); + table.ForeignKey( + name: "FK_MissionRun.MapMetadata#MapMetadata.TransformationMatrices#TransformationMatrices_MissionRun.MapMetadata#MapMetadata_MapMetad~", + column: x => x.MapMetadataMissionRunId, + principalTable: "MissionRun.MapMetadata#MapMetadata", + principalColumn: "MissionRunId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MissionTask.RobotPose#Pose.Orientation#Orientation", + columns: table => new + { + PoseMissionTaskId = table.Column(type: "nvarchar(450)", nullable: false), + W = table.Column(type: "real", nullable: false), + X = table.Column(type: "real", nullable: false), + Y = table.Column(type: "real", nullable: false), + Z = table.Column(type: "real", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MissionTask.RobotPose#Pose.Orientation#Orientation", x => x.PoseMissionTaskId); + table.ForeignKey( + name: "FK_MissionTask.RobotPose#Pose.Orientation#Orientation_MissionTask.RobotPose#Pose_PoseMissionTaskId", + column: x => x.PoseMissionTaskId, + principalTable: "MissionTask.RobotPose#Pose", + principalColumn: "MissionTaskId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MissionTask.RobotPose#Pose.Position#Position", + columns: table => new + { + PoseMissionTaskId = table.Column(type: "nvarchar(450)", nullable: false), + X = table.Column(type: "real", nullable: false), + Y = table.Column(type: "real", nullable: false), + Z = table.Column(type: "real", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MissionTask.RobotPose#Pose.Position#Position", x => x.PoseMissionTaskId); + table.ForeignKey( + name: "FK_MissionTask.RobotPose#Pose.Position#Position_MissionTask.RobotPose#Pose_PoseMissionTaskId", + column: x => x.PoseMissionTaskId, + principalTable: "MissionTask.RobotPose#Pose", + principalColumn: "MissionTaskId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Robot.Pose#Pose.Orientation#Orientation", + columns: table => new + { + PoseRobotId = table.Column(type: "nvarchar(450)", nullable: false), + W = table.Column(type: "real", nullable: false), + X = table.Column(type: "real", nullable: false), + Y = table.Column(type: "real", nullable: false), + Z = table.Column(type: "real", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Robot.Pose#Pose.Orientation#Orientation", x => x.PoseRobotId); + table.ForeignKey( + name: "FK_Robot.Pose#Pose.Orientation#Orientation_Robot.Pose#Pose_PoseRobotId", + column: x => x.PoseRobotId, + principalTable: "Robot.Pose#Pose", + principalColumn: "RobotId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Robot.Pose#Pose.Position#Position", + columns: table => new + { + PoseRobotId = table.Column(type: "nvarchar(450)", nullable: false), + X = table.Column(type: "real", nullable: false), + Y = table.Column(type: "real", nullable: false), + Z = table.Column(type: "real", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Robot.Pose#Pose.Position#Position", x => x.PoseRobotId); + table.ForeignKey( + name: "FK_Robot.Pose#Pose.Position#Position_Robot.Pose#Pose_PoseRobotId", + column: x => x.PoseRobotId, + principalTable: "Robot.Pose#Pose", + principalColumn: "RobotId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SafePosition.Pose#Pose.Orientation#Orientation", + columns: table => new + { + PoseSafePositionId = table.Column(type: "nvarchar(450)", nullable: false), + W = table.Column(type: "real", nullable: false), + X = table.Column(type: "real", nullable: false), + Y = table.Column(type: "real", nullable: false), + Z = table.Column(type: "real", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SafePosition.Pose#Pose.Orientation#Orientation", x => x.PoseSafePositionId); + table.ForeignKey( + name: "FK_SafePosition.Pose#Pose.Orientation#Orientation_SafePosition.Pose#Pose_PoseSafePositionId", + column: x => x.PoseSafePositionId, + principalTable: "SafePosition.Pose#Pose", + principalColumn: "SafePositionId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SafePosition.Pose#Pose.Position#Position", + columns: table => new + { + PoseSafePositionId = table.Column(type: "nvarchar(450)", nullable: false), + X = table.Column(type: "real", nullable: false), + Y = table.Column(type: "real", nullable: false), + Z = table.Column(type: "real", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SafePosition.Pose#Pose.Position#Position", x => x.PoseSafePositionId); + table.ForeignKey( + name: "FK_SafePosition.Pose#Pose.Position#Position_SafePosition.Pose#Pose_PoseSafePositionId", + column: x => x.PoseSafePositionId, + principalTable: "SafePosition.Pose#Pose", + principalColumn: "SafePositionId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.AddForeignKey( + name: "FK_Area_Deck_DeckId", + table: "Area", + column: "DeckId", + principalTable: "Deck", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Area_Installation_InstallationId", + table: "Area", + column: "InstallationId", + principalTable: "Installation", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Area_Plant_PlantId", + table: "Area", + column: "PlantId", + principalTable: "Plant", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Deck_Installation_InstallationId", + table: "Deck", + column: "InstallationId", + principalTable: "Installation", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Deck_Plant_PlantId", + table: "Deck", + column: "PlantId", + principalTable: "Plant", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MissionDefinition_Area_AreaId", + table: "MissionDefinition", + column: "AreaId", + principalTable: "Area", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_MissionDefinition_MissionRun_LastRunId", + table: "MissionDefinition", + column: "LastRunId", + principalTable: "MissionRun", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_MissionDefinition_Source_SourceId", + table: "MissionDefinition", + column: "SourceId", + principalTable: "Source", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MissionRun_Area_AreaId", + table: "MissionRun", + column: "AreaId", + principalTable: "Area", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_MissionRun_Robot_RobotId", + table: "MissionRun", + column: "RobotId", + principalTable: "Robot", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MissionTask_MissionRun_MissionRunId", + table: "MissionTask", + column: "MissionRunId", + principalTable: "MissionRun", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Plant_Installation_InstallationId", + table: "Plant", + column: "InstallationId", + principalTable: "Installation", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Robot_Area_CurrentAreaId", + table: "Robot", + column: "CurrentAreaId", + principalTable: "Area", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Robot_RobotModel_ModelId", + table: "Robot", + column: "ModelId", + principalTable: "RobotModel", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_SafePosition_Area_AreaId", + table: "SafePosition", + column: "AreaId", + principalTable: "Area", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_VideoStream_Robot_RobotId", + table: "VideoStream", + column: "RobotId", + principalTable: "Robot", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs b/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs index eb39638dd..a46fd8c3f 100644 --- a/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs +++ b/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs @@ -53,7 +53,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("PlantId"); - b.ToTable("Area"); + b.ToTable("Areas"); }); modelBuilder.Entity("Api.Database.Models.AssetDeck", b => @@ -74,7 +74,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("AssetDeck"); + b.ToTable("AssetDecks"); }); modelBuilder.Entity("Api.Database.Models.Deck", b => @@ -100,7 +100,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("PlantId"); - b.ToTable("Deck"); + b.ToTable("Decks"); }); modelBuilder.Entity("Api.Database.Models.Installation", b => @@ -124,7 +124,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("InstallationCode") .IsUnique(); - b.ToTable("Installation"); + b.ToTable("Installations"); }); modelBuilder.Entity("Api.Database.Models.MissionDefinition", b => @@ -170,7 +170,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SourceId"); - b.ToTable("MissionDefinition"); + b.ToTable("MissionDefinitions"); }); modelBuilder.Entity("Api.Database.Models.MissionRun", b => @@ -196,6 +196,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("EndTime") .HasColumnType("datetimeoffset"); + b.Property("ErrorDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorReason") + .HasColumnType("nvarchar(max)"); + b.Property("EstimatedDuration") .HasColumnType("bigint"); @@ -236,7 +242,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("RobotId"); - b.ToTable("MissionRun"); + b.ToTable("MissionRuns"); }); modelBuilder.Entity("Api.Database.Models.Plant", b => @@ -265,7 +271,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("PlantCode") .IsUnique(); - b.ToTable("Plant"); + b.ToTable("Plants"); }); modelBuilder.Entity("Api.Database.Models.Robot", b => @@ -329,7 +335,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ModelId"); - b.ToTable("Robot"); + b.ToTable("Robots"); }); modelBuilder.Entity("Api.Database.Models.RobotModel", b => @@ -359,7 +365,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Type") .IsUnique(); - b.ToTable("RobotModel"); + b.ToTable("RobotModels"); }); modelBuilder.Entity("Api.Database.Models.SafePosition", b => @@ -375,7 +381,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("AreaId"); - b.ToTable("SafePosition"); + b.ToTable("SafePositions"); }); modelBuilder.Entity("Api.Database.Models.Source", b => @@ -393,7 +399,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("Source"); + b.ToTable("Sources"); }); modelBuilder.Entity("Api.Database.Models.Area", b => @@ -423,7 +429,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.HasKey("AreaId"); - b1.ToTable("Area.DefaultLocalizationPose#Pose"); + b1.ToTable("Areas"); b1.WithOwner() .HasForeignKey("AreaId"); @@ -447,7 +453,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseAreaId"); - b2.ToTable("Area.DefaultLocalizationPose#Pose.Orientation#Orientation"); + b2.ToTable("Areas"); b2.WithOwner() .HasForeignKey("PoseAreaId"); @@ -469,7 +475,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseAreaId"); - b2.ToTable("Area.DefaultLocalizationPose#Pose.Position#Position"); + b2.ToTable("Areas"); b2.WithOwner() .HasForeignKey("PoseAreaId"); @@ -494,7 +500,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.HasKey("AreaId"); - b1.ToTable("Area.MapMetadata#MapMetadata"); + b1.ToTable("Areas"); b1.WithOwner() .HasForeignKey("AreaId"); @@ -524,7 +530,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("MapMetadataAreaId"); - b2.ToTable("Area.MapMetadata#MapMetadata.Boundary#Boundary"); + b2.ToTable("Areas"); b2.WithOwner() .HasForeignKey("MapMetadataAreaId"); @@ -549,7 +555,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("MapMetadataAreaId"); - b2.ToTable("Area.MapMetadata#MapMetadata.TransformationMatrices#TransformationMatrices"); + b2.ToTable("Areas"); b2.WithOwner() .HasForeignKey("MapMetadataAreaId"); @@ -605,7 +611,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("Api.Database.Models.Source", "Source") .WithMany() .HasForeignKey("SourceId") - .OnDelete(DeleteBehavior.Restrict) + .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Area"); @@ -624,7 +630,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("Api.Database.Models.Robot", "Robot") .WithMany() .HasForeignKey("RobotId") - .OnDelete(DeleteBehavior.Restrict) + .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.OwnsOne("Api.Database.Models.MapMetadata", "MapMetadata", b1 => @@ -639,7 +645,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.HasKey("MissionRunId"); - b1.ToTable("MissionRun.MapMetadata#MapMetadata"); + b1.ToTable("MissionRuns"); b1.WithOwner() .HasForeignKey("MissionRunId"); @@ -669,7 +675,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("MapMetadataMissionRunId"); - b2.ToTable("MissionRun.MapMetadata#MapMetadata.Boundary#Boundary"); + b2.ToTable("MissionRuns"); b2.WithOwner() .HasForeignKey("MapMetadataMissionRunId"); @@ -694,7 +700,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("MapMetadataMissionRunId"); - b2.ToTable("MissionRun.MapMetadata#MapMetadata.TransformationMatrices#TransformationMatrices"); + b2.ToTable("MissionRuns"); b2.WithOwner() .HasForeignKey("MapMetadataMissionRunId"); @@ -727,6 +733,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.Property("EndTime") .HasColumnType("datetimeoffset"); + b1.Property("ErrorDescription") + .HasColumnType("nvarchar(max)"); + + b1.Property("ErrorReason") + .HasColumnType("nvarchar(max)"); + b1.Property("IsarTaskId") .HasMaxLength(200) .HasColumnType("nvarchar(200)"); @@ -770,6 +782,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.Property("EndTime") .HasColumnType("datetimeoffset"); + b2.Property("ErrorDescription") + .HasColumnType("nvarchar(max)"); + + b2.Property("ErrorReason") + .HasColumnType("nvarchar(max)"); + b2.Property("InspectionType") .HasColumnType("int"); @@ -820,7 +838,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("MissionTaskId"); - b2.ToTable("MissionTask.InspectionTarget#Position"); + b2.ToTable("MissionTask"); b2.WithOwner() .HasForeignKey("MissionTaskId"); @@ -833,7 +851,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("MissionTaskId"); - b2.ToTable("MissionTask.RobotPose#Pose"); + b2.ToTable("MissionTask"); b2.WithOwner() .HasForeignKey("MissionTaskId"); @@ -857,7 +875,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b3.HasKey("PoseMissionTaskId"); - b3.ToTable("MissionTask.RobotPose#Pose.Orientation#Orientation"); + b3.ToTable("MissionTask"); b3.WithOwner() .HasForeignKey("PoseMissionTaskId"); @@ -879,7 +897,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b3.HasKey("PoseMissionTaskId"); - b3.ToTable("MissionTask.RobotPose#Pose.Position#Position"); + b3.ToTable("MissionTask"); b3.WithOwner() .HasForeignKey("PoseMissionTaskId"); @@ -929,7 +947,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("Api.Database.Models.RobotModel", "Model") .WithMany() .HasForeignKey("ModelId") - .OnDelete(DeleteBehavior.Restrict) + .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => @@ -939,7 +957,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.HasKey("RobotId"); - b1.ToTable("Robot.Pose#Pose"); + b1.ToTable("Robots"); b1.WithOwner() .HasForeignKey("RobotId"); @@ -963,7 +981,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseRobotId"); - b2.ToTable("Robot.Pose#Pose.Orientation#Orientation"); + b2.ToTable("Robots"); b2.WithOwner() .HasForeignKey("PoseRobotId"); @@ -985,7 +1003,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseRobotId"); - b2.ToTable("Robot.Pose#Pose.Position#Position"); + b2.ToTable("Robots"); b2.WithOwner() .HasForeignKey("PoseRobotId"); @@ -1059,7 +1077,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.HasKey("SafePositionId"); - b1.ToTable("SafePosition.Pose#Pose"); + b1.ToTable("SafePositions"); b1.WithOwner() .HasForeignKey("SafePositionId"); @@ -1083,7 +1101,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseSafePositionId"); - b2.ToTable("SafePosition.Pose#Pose.Orientation#Orientation"); + b2.ToTable("SafePositions"); b2.WithOwner() .HasForeignKey("PoseSafePositionId"); @@ -1105,7 +1123,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseSafePositionId"); - b2.ToTable("SafePosition.Pose#Pose.Position#Position"); + b2.ToTable("SafePositions"); b2.WithOwner() .HasForeignKey("PoseSafePositionId");