DD.WellWorkover.Cloud/AsbCloudDb/Migrations/20231216060437_Update_Subsystems.cs
2023-12-16 12:42:42 +05:00

72 lines
3.6 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Update_Subsystems : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_subsystem_operation_time");
migrationBuilder.DeleteData(
table: "t_subsystem",
keyColumn: "id",
keyValue: 2);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_subsystem_operation_time",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
id_subsystem = table.Column<int>(type: "integer", nullable: false),
id_telemetry = table.Column<int>(type: "integer", nullable: false, comment: "ИД телеметрии по которой выдается информация"),
date_end = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "дата/время выключения подсистемы"),
date_start = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "дата/время включения подсистемы"),
depth_end = table.Column<float>(type: "real", nullable: true, comment: "глубина забоя на момент выключения подсистемы"),
depth_start = table.Column<float>(type: "real", nullable: true, comment: "глубина забоя на момент включения подсистемы")
},
constraints: table =>
{
table.PrimaryKey("PK_t_subsystem_operation_time", x => x.id);
table.ForeignKey(
name: "FK_t_subsystem_operation_time_t_subsystem_id_subsystem",
column: x => x.id_subsystem,
principalTable: "t_subsystem",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_subsystem_operation_time_t_telemetry_id_telemetry",
column: x => x.id_telemetry,
principalTable: "t_telemetry",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "наработки подсистем");
migrationBuilder.InsertData(
table: "t_subsystem",
columns: new[] { "id", "description", "name" },
values: new object[] { 2, "Алгоритм поиска оптимальных параметров бурения САУБ", "MSE" });
migrationBuilder.CreateIndex(
name: "IX_t_subsystem_operation_time_id_subsystem",
table: "t_subsystem_operation_time",
column: "id_subsystem");
migrationBuilder.CreateIndex(
name: "IX_t_subsystem_operation_time_id_telemetry",
table: "t_subsystem_operation_time",
column: "id_telemetry");
}
}
}