DD.WellWorkover.Cloud/AsbCloudDb/Migrations/20240611044842_Add_ProcessMapPlanRotor_And_Slide.cs
Olga Nemt 089ce64e65 Разделение таблицы РТК-план-бурение на Ротор и Слайд.
Разделение ProcessMaplPlanDrillingController на Ротор и Слайд.
Добавлены 2 Dto для Ротора и Слайда
2024-06-11 10:31:03 +05:00

229 lines
16 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
/// <inheritdoc />
public partial class Add_ProcessMapPlanRotor_And_Slide : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_process_map_plan_rotor",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
rop_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Максимально допустимая скорость, м/ч"),
max_allowable_pressure = table.Column<double>(type: "double precision", nullable: false, comment: "Максимально допустимое давление, атм"),
differential_pressure_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, атм. Уставка"),
differential_pressure_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, атм. Ограничение"),
weight_on_bit_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Нагрузка, т. Уставка"),
weight_on_bit_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Нагрузка, т. Ограничение"),
top_drive_torque_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Момент на ВСП, кН*м. Уставка"),
top_drive_torque_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Момент на ВСП, кН*м. Ограничение"),
revolution_per_minute_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Обороты на ВСП, об/мин. Уставка"),
revolutions_per_minute_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Обороты на ВСП, об/мин. Ограничение"),
flow_rate_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Расход л/с. Уставка"),
flow_rate_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Расход л/с. Ограничение"),
note = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false, comment: "Примечание"),
id_author = table.Column<int>(type: "integer", nullable: false, comment: "Автор"),
id_editor = table.Column<int>(type: "integer", nullable: true, comment: "Редактор"),
creation = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "дата создания"),
obsolete = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true, comment: "дата устаревания"),
id_state = table.Column<int>(type: "integer", nullable: false, comment: "ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная"),
id_previous = table.Column<int>(type: "integer", nullable: true, comment: "ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная"),
id_well = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
id_wellsection_type = table.Column<int>(type: "integer", 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: "Глубина по стволу до, м")
},
constraints: table =>
{
table.PrimaryKey("PK_t_process_map_plan_rotor", x => x.id);
table.ForeignKey(
name: "FK_t_process_map_plan_rotor_t_process_map_plan_rotor_id_previo~",
column: x => x.id_previous,
principalTable: "t_process_map_plan_rotor",
principalColumn: "id");
table.ForeignKey(
name: "FK_t_process_map_plan_rotor_t_user_id_author",
column: x => x.id_author,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_t_process_map_plan_rotor_t_user_id_editor",
column: x => x.id_editor,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_t_process_map_plan_rotor_t_well_id_well",
column: x => x.id_well,
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_process_map_plan_rotor_t_well_section_type_id_wellsection~",
column: x => x.id_wellsection_type,
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "РТК план бурение ротор");
migrationBuilder.CreateTable(
name: "t_process_map_plan_slide",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
rop_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Максимально допустимая скорость, м/ч"),
max_allowable_pressure = table.Column<double>(type: "double precision", nullable: false, comment: "Максимально допустимое давление, атм"),
differential_pressure_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, атм. Уставка"),
differential_pressure_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Перепад давления, атм. Ограничение"),
weight_on_bit_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Нагрузка, т. Уставка"),
weight_on_bit_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Нагрузка, т. Ограничение"),
flow_rate_plan = table.Column<double>(type: "double precision", nullable: false, comment: "Расход л/с. Уставка"),
flow_rate_limit_max = table.Column<double>(type: "double precision", nullable: false, comment: "Расход л/с. Ограничение"),
design_spring = table.Column<double>(type: "double precision", nullable: false, comment: "Расчётная пружина, градус"),
tool_buckling = table.Column<double>(type: "double precision", nullable: false, comment: "Складывание инструмента, м"),
note = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false, comment: "Примечание"),
id_author = table.Column<int>(type: "integer", nullable: false, comment: "Автор"),
id_editor = table.Column<int>(type: "integer", nullable: true, comment: "Редактор"),
creation = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "дата создания"),
obsolete = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true, comment: "дата устаревания"),
id_state = table.Column<int>(type: "integer", nullable: false, comment: "ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная"),
id_previous = table.Column<int>(type: "integer", nullable: true, comment: "ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная"),
id_well = table.Column<int>(type: "integer", nullable: false, comment: "Id скважины"),
id_wellsection_type = table.Column<int>(type: "integer", 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: "Глубина по стволу до, м")
},
constraints: table =>
{
table.PrimaryKey("PK_t_process_map_plan_slide", x => x.id);
table.ForeignKey(
name: "FK_t_process_map_plan_slide_t_process_map_plan_drilling_id_pre~",
column: x => x.id_previous,
principalTable: "t_process_map_plan_drilling",
principalColumn: "id");
table.ForeignKey(
name: "FK_t_process_map_plan_slide_t_user_id_author",
column: x => x.id_author,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_t_process_map_plan_slide_t_user_id_editor",
column: x => x.id_editor,
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_t_process_map_plan_slide_t_well_id_well",
column: x => x.id_well,
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_process_map_plan_slide_t_well_section_type_id_wellsection~",
column: x => x.id_wellsection_type,
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "РТК план бурение слайд");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_rotor_id_author",
table: "t_process_map_plan_rotor",
column: "id_author");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_rotor_id_editor",
table: "t_process_map_plan_rotor",
column: "id_editor");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_rotor_id_previous",
table: "t_process_map_plan_rotor",
column: "id_previous");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_rotor_id_well",
table: "t_process_map_plan_rotor",
column: "id_well");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_rotor_id_wellsection_type",
table: "t_process_map_plan_rotor",
column: "id_wellsection_type");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_slide_id_author",
table: "t_process_map_plan_slide",
column: "id_author");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_slide_id_editor",
table: "t_process_map_plan_slide",
column: "id_editor");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_slide_id_previous",
table: "t_process_map_plan_slide",
column: "id_previous");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_slide_id_well",
table: "t_process_map_plan_slide",
column: "id_well");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_plan_slide_id_wellsection_type",
table: "t_process_map_plan_slide",
column: "id_wellsection_type");
migrationBuilder.Sql(@"INSERT INTO public.t_process_map_plan_rotor
(id, id_wellsection_type, rop_plan, depth_start, depth_end, differential_pressure_plan,
differential_pressure_limit_max, weight_on_bit_plan, weight_on_bit_limit_max,
top_drive_torque_plan, top_drive_torque_limit_max, revolution_per_minute_plan,
revolutions_per_minute_limit_max, flow_rate_plan, flow_rate_limit_max, note,
max_allowable_pressure, id_author, creation, id_state, id_well, id_editor, obsolete, id_previous)
SELECT id, id_wellsection_type, rop_plan, depth_start, depth_end, delta_pressure_plan,
delta_pressure_limit_max, axial_load_plan, axial_load_limit_max,
top_drive_torque_plan, top_drive_torque_limit_max, top_drive_speed_plan,
top_drive_speed_limit_max, flow_plan, flow_limit_max, comment, 0, id_author, creation, id_state, id_well,
id_editor, obsolete, id_previous
FROM public.t_process_map_plan_drilling WHERE id_mode = 1");
migrationBuilder.Sql(@"INSERT INTO public.t_process_map_plan_slide
(id, id_wellsection_type, rop_plan, depth_start, depth_end, differential_pressure_plan,
differential_pressure_limit_max, weight_on_bit_plan, weight_on_bit_limit_max,
flow_rate_plan, flow_rate_limit_max, note, max_allowable_pressure, id_author, creation,
id_state, id_well, design_spring, tool_buckling, id_editor, obsolete, id_previous)
SELECT id, id_wellsection_type, rop_plan, depth_start, depth_end, delta_pressure_plan,
delta_pressure_limit_max, axial_load_plan, axial_load_limit_max,
flow_plan, flow_limit_max, comment, 0, id_author, creation, id_state, id_well, 0, 0, id_editor, obsolete, id_previous
FROM public.t_process_map_plan_drilling
WHERE id_mode = 2");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_process_map_plan_rotor");
migrationBuilder.DropTable(
name: "t_process_map_plan_slide");
}
}
}