DD.WellWorkover.Cloud/AsbCloudDb/Migrations/20210914105045_RefactorTelemetryData.cs

142 lines
13 KiB
C#
Raw Normal View History

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace AsbCloudDb.Migrations
{
public partial class RefactorTelemetryData : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "t_data_saub_base_t_telemetry_id_fk", table: "t_data_saub_base");
migrationBuilder.DropPrimaryKey(name: "PK_t_data_saub_base", table: "t_data_saub_base");
migrationBuilder.RenameTable(name: "t_data_saub_base", newName: "t_telemetry_data_saub");
migrationBuilder.RenameIndex(name: "IX_t_data_saub_base_id_telemetry", newName: "IX_t_telemetry_data_saub_id_telemetry");
migrationBuilder.AddPrimaryKey(name: "PK_t_telemetry_data_saub", table: "t_telemetry_data_saub", column: "id");
migrationBuilder.AddForeignKey(
name: "t_telemetry_data_saub_t_telemetry_id_fk",
table: "t_telemetry_data_saub",
column: "id_telemetry",
principalTable: "t_telemetry",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.CreateTable(
name: "t_telemetry_data_spin",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
id_telemetry = table.Column<int>(type: "integer", nullable: false),
date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "'2021-10-19 18:23:54+05'"),
top_drive_speed = table.Column<double>(type: "double precision", nullable: true, comment: "Скорость СВП"),
top_drive_speed_min = table.Column<double>(type: "double precision", nullable: true, comment: "нижний предел"),
top_drive_speed_max = table.Column<double>(type: "double precision", nullable: true, comment: "верхний предел"),
top_drive_speed_offset = table.Column<double>(type: "double precision", nullable: true, comment: "смещение"),
top_drive_speed_err = table.Column<int>(type: "integer", nullable: true),
top_drive_torque = table.Column<double>(type: "double precision", nullable: true, comment: "Момент СВП"),
top_drive_torque_min = table.Column<double>(type: "double precision", nullable: true),
top_drive_torque_max = table.Column<double>(type: "double precision", nullable: true),
top_drive_torque_offset = table.Column<double>(type: "double precision", nullable: true),
top_drive_torque_err = table.Column<int>(type: "integer", nullable: true),
top_drive_speed_sp_from = table.Column<double>(type: "double precision", nullable: true, comment: "Заданная скорость c СВП"),
top_drive_speed_sp_from_min = table.Column<double>(type: "double precision", nullable: true),
top_drive_speed_sp_from_max = table.Column<double>(type: "double precision", nullable: true),
top_drive_speed_sp_from_offset = table.Column<double>(type: "double precision", nullable: true),
top_drive_speed_sp_from_err = table.Column<int>(type: "integer", nullable: true),
top_drive_torque_sp_from = table.Column<double>(type: "double precision", nullable: true, comment: "Заданный момент c СВП"),
top_drive_torque_sp_from_min = table.Column<double>(type: "double precision", nullable: true),
top_drive_torque_sp_from_max = table.Column<double>(type: "double precision", nullable: true),
top_drive_torque_sp_from_offset = table.Column<double>(type: "double precision", nullable: true),
top_drive_torque_sp_from_err = table.Column<int>(type: "integer", nullable: true),
top_drive_speed_sp_to = table.Column<double>(type: "double precision", nullable: true, comment: "Задание скорости на СВП"),
top_drive_speed_sp_to_min = table.Column<double>(type: "double precision", nullable: true),
top_drive_speed_sp_to_max = table.Column<double>(type: "double precision", nullable: true),
top_drive_speed_sp_to_offset = table.Column<double>(type: "double precision", nullable: true),
top_drive_speed_sp_to_err = table.Column<int>(type: "integer", nullable: true),
top_drive_torque_sp_to = table.Column<double>(type: "double precision", nullable: true, comment: "Задание момента на СВП"),
top_drive_torque_sp_to_min = table.Column<double>(type: "double precision", nullable: true),
top_drive_torque_sp_to_max = table.Column<double>(type: "double precision", nullable: true),
top_drive_torque_sp_to_offset = table.Column<double>(type: "double precision", nullable: true),
top_drive_torque_sp_to_err = table.Column<int>(type: "integer", nullable: true),
w2800 = table.Column<int>(type: "integer", nullable: true, comment: "Установка нуля энкодера"),
w2810 = table.Column<int>(type: "integer", nullable: true, comment: " автоматический сброс блокировки"),
mode = table.Column<int>(type: "integer", nullable: true, comment: "Выбранный режим управления"),
w2808 = table.Column<int>(type: "integer", nullable: true, comment: "Неисправность энкодера"),
torque_starting = table.Column<double>(type: "double precision", nullable: true, comment: " Страгивающий момент"),
rotor_torque_avg = table.Column<double>(type: "double precision", nullable: true, comment: " Момент в роторе средний"),
encoder_resolution = table.Column<double>(name: "encoder_resolution ", type: "double precision", nullable: true, comment: " Разрешение энкодера"),
ratio = table.Column<double>(type: "double precision", nullable: true, comment: " Коэффициент редукции редектора"),
torque_right_limit = table.Column<double>(type: "double precision", nullable: true, comment: "Ограничение крутящего момента вправо"),
torque_left_limit = table.Column<double>(type: "double precision", nullable: true, comment: "Ограничение крутящего момента влево"),
revols_right_limit = table.Column<double>(type: "double precision", nullable: true, comment: "Ограничение числа оборотов вправо"),
revols_left_limit = table.Column<double>(type: "double precision", nullable: true, comment: "Ограничение числа оборотов влево"),
speed_right_sp = table.Column<double>(type: "double precision", nullable: true, comment: "Заданная скорость вращения вправо"),
speed_left_sp = table.Column<double>(type: "double precision", nullable: true, comment: "Заданная скорость вращения влево"),
revols_right_total = table.Column<double>(type: "double precision", nullable: true, comment: "Суммарное количество оборотов вправо"),
revols_left_total = table.Column<double>(type: "double precision", nullable: true, comment: "Суммарное количество оборотов влево"),
turn_right_once_by_torque = table.Column<double>(type: "double precision", nullable: true, comment: "Доворот по моменту единожды вправо"),
turn_left_once_by_torque = table.Column<double>(type: "double precision", nullable: true, comment: "Доворот по моменту единожды влево"),
turn_right_once_by_angle = table.Column<double>(type: "double precision", nullable: true, comment: "Доворот по градусам единожды вправо"),
turn_left_once_by_angle = table.Column<double>(type: "double precision", nullable: true, comment: "Доворот по градусам единожды влево"),
turn_right_once_by_revols = table.Column<double>(type: "double precision", nullable: true, comment: "Доворот по оборотам единожды вправо"),
turn_left_once_by_revols = table.Column<double>(type: "double precision", nullable: true, comment: "Доворот по оборотам единожды влево"),
break_angle_k = table.Column<double>(type: "double precision", nullable: true, comment: "Коэффициент для расчёта за какой угол нужно тормозить"),
reverse_k_torque = table.Column<double>(type: "double precision", nullable: true, comment: "Коэффициент на который умножается момент, для того чтобы система поняла что мы движемся в обратную сторону"),
position_zero = table.Column<double>(type: "double precision", nullable: true, comment: "Нулевая позиция осциляции"),
position_right = table.Column<double>(type: "double precision", nullable: true, comment: "Крайний правый угол осциляции"),
torque_ramp_time = table.Column<double>(type: "double precision", nullable: true, comment: "Время нарастания момента"),
ver = table.Column<double>(type: "double precision", nullable: true, comment: "Версия ПО ПЛК"),
reverse_speed_sp_zero_time = table.Column<int>(type: "integer", nullable: true, comment: "Время выдачи сигнала нулевой скорости на при смене направления"),
unlock_by_sector_out = table.Column<double>(type: "double precision", nullable: true, comment: " Градус отклонения от сектора для автоматического сброса блокировки"),
pid_mux_torque_left_limit = table.Column<double>(type: "double precision", nullable: true, comment: " Момент при котором определяется ехать назад по моменту или по скорости"),
state = table.Column<int>(type: "integer", nullable: true, comment: "Переменная этапа"),
break_angle_left = table.Column<double>(type: "double precision", nullable: true, comment: "Угол торможения влево при работе по моменту")
},
constraints: table =>
{
table.PrimaryKey("PK_t_telemetry_data_spin", x => x.id);
table.ForeignKey(
name: "t_telemetry_data_spin_t_telemetry_id_fk",
column: x => x.id_telemetry,
principalTable: "t_telemetry",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
},
comment: "набор основных данных по SpinMaster");
migrationBuilder.CreateIndex(
name: "IX_t_telemetry_data_spin_id_telemetry",
table: "t_telemetry_data_spin",
column: "id_telemetry");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_telemetry_data_spin");
migrationBuilder.DropForeignKey(name: "t_telemetry_data_saub_t_telemetry_id_fk", table: "t_telemetry_data_saub");
migrationBuilder.DropPrimaryKey(name: "PK_t_telemetry_data_saub", table: "t_telemetry_data_saub");
migrationBuilder.RenameTable(name: "t_telemetry_data_saub", newName: "t_data_saub_base");
migrationBuilder.RenameIndex(name: "IX_t_telemetry_data_saub_id_telemetry", newName: "IX_t_data_saub_base_id_telemetry");
migrationBuilder.AddPrimaryKey(name: "PK_t_telemetry_data_saub", table: "t_data_saub_base", column: "id");
migrationBuilder.AddForeignKey(
name: "t_data_saub_t_telemetry_id_fk",
table: "t_data_saub_base",
column: "id_telemetry",
principalTable: "t_telemetry",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
}
}
}