using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace AsbCloudDb.Migrations
{
    public partial class DeleteTable_t_drill_flow_chart : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "t_drill_flow_chart");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "t_drill_flow_chart",
                columns: table => new
                {
                    id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    well_id = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
                    axial_load_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальная нагрузка"),
                    axial_load_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальная нагрузка"),
                    depth_end = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина окончания интервала"),
                    depth_start = table.Column<double>(type: "double precision", nullable: false, comment: "Стартовая глубина"),
                    flow_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный расход"),
                    flow_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный расход"),
                    id_operation_category = table.Column<int>(type: "integer", nullable: false, comment: "Id типа операции"),
                    last_update = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата последнего изменения"),
                    pressure_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальное давление"),
                    pressure_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальное давление"),
                    rotor_speed_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальные обороты на ВСП"),
                    rotor_speed_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальные обороты на ВСП"),
                    rotor_torque_max = table.Column<double>(type: "double precision", nullable: false, comment: "Максимальный момент на ВСП"),
                    rotor_torque_min = table.Column<double>(type: "double precision", nullable: false, comment: "Минимальный момент на ВСП")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_drill_flow_chart", x => x.id);
                    table.ForeignKey(
                        name: "FK_t_drill_flow_chart_t_well_well_id",
                        column: x => x.well_id,
                        principalTable: "t_well",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "Параметры коридоров бурения (диапазоны параметров бурения)");

            migrationBuilder.CreateIndex(
                name: "IX_t_drill_flow_chart_id_operation_category",
                table: "t_drill_flow_chart",
                column: "id_operation_category");

            migrationBuilder.CreateIndex(
                name: "IX_t_drill_flow_chart_well_id",
                table: "t_drill_flow_chart",
                column: "well_id");
        }
    }
}