using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AsbCloudDb.Migrations
{
    public partial class Update_ProcessMapWellboreDevelopment : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.RenameColumn(
                name: "setpoint_tights",
                table: "t_process_map_wellbore_development",
                newName: "setpoint_tight");

            migrationBuilder.RenameColumn(
                name: "setpoint_drags",
                table: "t_process_map_wellbore_development",
                newName: "setpoint_drag");

            migrationBuilder.AlterTable(
                name: "t_process_map_wellbore_development",
                comment: "РТК план проработка скважины",
                oldComment: "Проработка скважины");

            migrationBuilder.AlterColumn<double>(
                name: "torque",
                table: "t_process_map_wellbore_development",
                type: "double precision",
                nullable: false,
                comment: "Момент, кН*м",
                oldClrType: typeof(double),
                oldType: "double precision",
                oldComment: "Момент, кН м");

            migrationBuilder.AlterColumn<double>(
                name: "pressure",
                table: "t_process_map_wellbore_development",
                type: "double precision",
                nullable: false,
                comment: "Давление, атм",
                oldClrType: typeof(double),
                oldType: "double precision",
                oldComment: "Давление");

            migrationBuilder.AlterColumn<double>(
                name: "depth_start",
                table: "t_process_map_wellbore_development",
                type: "double precision",
                nullable: false,
                comment: "Стартовая глубина, м",
                oldClrType: typeof(double),
                oldType: "double precision",
                oldComment: "Стартовая глубина");

            migrationBuilder.AlterColumn<double>(
                name: "depth_end",
                table: "t_process_map_wellbore_development",
                type: "double precision",
                nullable: false,
                comment: "Окончательная глубина, м",
                oldClrType: typeof(double),
                oldType: "double precision",
                oldComment: "Окончательная глубина");

            migrationBuilder.AddColumn<int>(
                name: "id_user",
                table: "t_process_map_wellbore_development",
                type: "integer",
                nullable: false,
                defaultValue: 0,
                comment: "Id пользователя");

            migrationBuilder.CreateIndex(
                name: "IX_t_process_map_wellbore_development_id_user",
                table: "t_process_map_wellbore_development",
                column: "id_user");

            migrationBuilder.AddForeignKey(
                name: "FK_t_process_map_wellbore_development_t_user_id_user",
                table: "t_process_map_wellbore_development",
                column: "id_user",
                principalTable: "t_user",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_t_process_map_wellbore_development_t_user_id_user",
                table: "t_process_map_wellbore_development");

            migrationBuilder.DropIndex(
                name: "IX_t_process_map_wellbore_development_id_user",
                table: "t_process_map_wellbore_development");

            migrationBuilder.DropColumn(
                name: "id_user",
                table: "t_process_map_wellbore_development");

            migrationBuilder.RenameColumn(
                name: "setpoint_tight",
                table: "t_process_map_wellbore_development",
                newName: "setpoint_tights");

            migrationBuilder.RenameColumn(
                name: "setpoint_drag",
                table: "t_process_map_wellbore_development",
                newName: "setpoint_drags");

            migrationBuilder.AlterTable(
                name: "t_process_map_wellbore_development",
                comment: "Проработка скважины",
                oldComment: "РТК план проработка скважины");

            migrationBuilder.AlterColumn<double>(
                name: "torque",
                table: "t_process_map_wellbore_development",
                type: "double precision",
                nullable: false,
                comment: "Момент, кН м",
                oldClrType: typeof(double),
                oldType: "double precision",
                oldComment: "Момент, кН*м");

            migrationBuilder.AlterColumn<double>(
                name: "pressure",
                table: "t_process_map_wellbore_development",
                type: "double precision",
                nullable: false,
                comment: "Давление",
                oldClrType: typeof(double),
                oldType: "double precision",
                oldComment: "Давление, атм");

            migrationBuilder.AlterColumn<double>(
                name: "depth_start",
                table: "t_process_map_wellbore_development",
                type: "double precision",
                nullable: false,
                comment: "Стартовая глубина",
                oldClrType: typeof(double),
                oldType: "double precision",
                oldComment: "Стартовая глубина, м");

            migrationBuilder.AlterColumn<double>(
                name: "depth_end",
                table: "t_process_map_wellbore_development",
                type: "double precision",
                nullable: false,
                comment: "Окончательная глубина",
                oldClrType: typeof(double),
                oldType: "double precision",
                oldComment: "Окончательная глубина, м");
        }
    }
}