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

#nullable disable

namespace AsbCloudDb.Migrations
{
    public partial class Add_ProcessMapWellboreDevelopment : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "t_process_map_wellbore_development",
                columns: table => new
                {
                    id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    id_well = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
                    last_update = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата последнего изменения"),
                    depth_start = table.Column<double>(type: "double precision", nullable: false, comment: "Стартовая глубина"),
                    depth_end = table.Column<double>(type: "double precision", nullable: false, comment: "Окончательная глубина"),
                    repeats = table.Column<double>(type: "double precision", nullable: false, comment: "Количество повторений"),
                    spin_upward = table.Column<double>(type: "double precision", nullable: false, comment: "Вращение при движении вверх, об/мин"),
                    spin_downward = table.Column<double>(type: "double precision", nullable: false, comment: "Вращение при движении вниз, об/мин"),
                    speed_upward = table.Column<double>(type: "double precision", nullable: false, comment: "Скорость подъёма, м/ч"),
                    speed_downward = table.Column<double>(type: "double precision", nullable: false, comment: "Скорость спуска, м/ч"),
                    setpoint_drags = table.Column<double>(type: "double precision", nullable: false, comment: "Уставка зятяжки, т"),
                    setpoint_tights = table.Column<double>(type: "double precision", nullable: false, comment: "Уставка посадки, т"),
                    pressure = table.Column<double>(type: "double precision", nullable: false, comment: "Давление"),
                    torque = table.Column<double>(type: "double precision", nullable: false, comment: "Момент, кН м"),
                    comment = table.Column<string>(type: "text", nullable: true, comment: "Комментарий")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_process_map_wellbore_development", x => x.id);
                    table.ForeignKey(
                        name: "FK_t_process_map_wellbore_development_t_well_id_well",
                        column: x => x.id_well,
                        principalTable: "t_well",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "Проработка скважины");

            migrationBuilder.CreateIndex(
                name: "IX_t_process_map_wellbore_development_id_well",
                table: "t_process_map_wellbore_development",
                column: "id_well");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "t_process_map_wellbore_development");
        }
    }
}