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

#nullable disable

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

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "t_drill_params",
                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 скважины"),
                    id_wellsection_type = table.Column<int>(type: "integer", nullable: false, comment: "Id с типом секции скважины"),
                    axial_load_avg = table.Column<double>(type: "double precision", nullable: false, comment: "Средняя нагрузка"),
                    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_avg = 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: "Минимальный расход"),
                    pressure_avg = table.Column<double>(type: "double precision", 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_avg = 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_avg = 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_params", x => x.id);
                    table.ForeignKey(
                        name: "FK_t_drill_params_t_well_well_id",
                        column: x => x.well_id,
                        principalTable: "t_well",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "t_drill_params_t_well_section_type_id_fk",
                        column: x => x.id_wellsection_type,
                        principalTable: "t_well_section_type",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "Режим бурения в секции (диапазоны параметров бурения)");

            migrationBuilder.CreateIndex(
                name: "IX_t_drill_params_id_wellsection_type",
                table: "t_drill_params",
                column: "id_wellsection_type");

            migrationBuilder.CreateIndex(
                name: "IX_t_drill_params_well_id",
                table: "t_drill_params",
                column: "well_id");
        }
    }
}