using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace RobotNet10.RobotApp.Data.Migrations.TuneDb
{
///
public partial class AddTunDb : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "parameter_sets",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
Name = table.Column(type: "TEXT", maxLength: 200, nullable: false),
Description = table.Column(type: "TEXT", maxLength: 500, nullable: false),
CreatedAt = table.Column(type: "TEXT", nullable: false),
UpdatedAt = table.Column(type: "TEXT", nullable: true),
IsDefault = table.Column(type: "INTEGER", nullable: false),
Version = table.Column(type: "INTEGER", nullable: false),
ControllerType = table.Column(type: "INTEGER", nullable: false),
MovePidConfig = table.Column(type: "TEXT", nullable: false),
RotatePidConfig = table.Column(type: "TEXT", nullable: false),
PurePursuitConfig = table.Column(type: "TEXT", nullable: false),
StanleyConfig = table.Column(type: "TEXT", nullable: false),
EstimatorConfig = table.Column(type: "TEXT", nullable: false),
SignalConfig = table.Column(type: "TEXT", nullable: false),
MotorDynamicsConfig = table.Column(type: "TEXT", nullable: false),
NavigationConfig = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_parameter_sets", x => x.Id);
});
migrationBuilder.CreateTable(
name: "test_runs",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
ScenarioId = table.Column(type: "TEXT", nullable: false),
ParameterSetId = table.Column(type: "TEXT", nullable: false),
StartTime = table.Column(type: "TEXT", nullable: false),
EndTime = table.Column(type: "TEXT", nullable: true),
Status = table.Column(type: "INTEGER", nullable: false),
Duration = table.Column(type: "REAL", nullable: false),
Notes = table.Column(type: "TEXT", maxLength: 1000, nullable: true),
ErrorMessage = table.Column(type: "TEXT", maxLength: 1000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_test_runs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "test_scenarios",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
Name = table.Column(type: "TEXT", maxLength: 200, nullable: false),
Description = table.Column(type: "TEXT", maxLength: 500, nullable: false),
Type = table.Column(type: "INTEGER", nullable: false),
CreatedAt = table.Column(type: "TEXT", nullable: false),
IsDefault = table.Column(type: "INTEGER", nullable: false),
ConfigJson = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_test_scenarios", x => x.Id);
});
migrationBuilder.CreateTable(
name: "safety_violations",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
TestRunId = table.Column(type: "TEXT", nullable: false),
Timestamp = table.Column(type: "TEXT", nullable: false),
Type = table.Column(type: "INTEGER", nullable: false),
Severity = table.Column(type: "INTEGER", nullable: false),
Value = table.Column(type: "REAL", nullable: false),
Threshold = table.Column(type: "REAL", nullable: false),
Message = table.Column(type: "TEXT", maxLength: 500, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_safety_violations", x => x.Id);
table.ForeignKey(
name: "FK_safety_violations_test_runs_TestRunId",
column: x => x.TestRunId,
principalTable: "test_runs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "test_metrics",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
TestRunId = table.Column(type: "TEXT", nullable: false),
CrossTrackErrorRMS = table.Column(type: "REAL", nullable: false),
CrossTrackErrorPeak = table.Column(type: "REAL", nullable: false),
CrossTrackErrorMean = table.Column(type: "REAL", nullable: false),
CrossTrackErrorStdDev = table.Column(type: "REAL", nullable: false),
HeadingErrorRMS = table.Column(type: "REAL", nullable: false),
HeadingErrorPeak = table.Column(type: "REAL", nullable: false),
GoalPositionError = table.Column(type: "REAL", nullable: false),
GoalHeadingError = table.Column(type: "REAL", nullable: false),
VelocityStdDev = table.Column(type: "REAL", nullable: false),
AccelerationStdDev = table.Column(type: "REAL", nullable: false),
PathLengthRatio = table.Column(type: "REAL", nullable: false),
CompletionTime = table.Column(type: "REAL", nullable: false),
AverageSpeed = table.Column(type: "REAL", nullable: false),
MaxSpeed = table.Column(type: "REAL", nullable: false),
OverallScore = table.Column(type: "REAL", nullable: false),
TrackingScore = table.Column(type: "REAL", nullable: false),
SmoothnessScore = table.Column(type: "REAL", nullable: false),
EfficiencyScore = table.Column(type: "REAL", nullable: false),
PassedCriteria = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_test_metrics", x => x.Id);
table.ForeignKey(
name: "FK_test_metrics_test_runs_TestRunId",
column: x => x.TestRunId,
principalTable: "test_runs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_parameter_sets_CreatedAt",
table: "parameter_sets",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_parameter_sets_IsDefault",
table: "parameter_sets",
column: "IsDefault");
migrationBuilder.CreateIndex(
name: "IX_parameter_sets_Name",
table: "parameter_sets",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_safety_violations_TestRunId",
table: "safety_violations",
column: "TestRunId");
migrationBuilder.CreateIndex(
name: "IX_safety_violations_TestRunId_Timestamp",
table: "safety_violations",
columns: new[] { "TestRunId", "Timestamp" });
migrationBuilder.CreateIndex(
name: "IX_safety_violations_Timestamp",
table: "safety_violations",
column: "Timestamp");
migrationBuilder.CreateIndex(
name: "IX_test_metrics_TestRunId",
table: "test_metrics",
column: "TestRunId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_test_runs_ParameterSetId",
table: "test_runs",
column: "ParameterSetId");
migrationBuilder.CreateIndex(
name: "IX_test_runs_ScenarioId",
table: "test_runs",
column: "ScenarioId");
migrationBuilder.CreateIndex(
name: "IX_test_runs_ScenarioId_ParameterSetId",
table: "test_runs",
columns: new[] { "ScenarioId", "ParameterSetId" });
migrationBuilder.CreateIndex(
name: "IX_test_runs_StartTime",
table: "test_runs",
column: "StartTime");
migrationBuilder.CreateIndex(
name: "IX_test_runs_Status",
table: "test_runs",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_test_scenarios_CreatedAt",
table: "test_scenarios",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_test_scenarios_Name",
table: "test_scenarios",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_test_scenarios_Type",
table: "test_scenarios",
column: "Type");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "parameter_sets");
migrationBuilder.DropTable(
name: "safety_violations");
migrationBuilder.DropTable(
name: "test_metrics");
migrationBuilder.DropTable(
name: "test_scenarios");
migrationBuilder.DropTable(
name: "test_runs");
}
}
}