DD.WellWorkover.Cloud/AsbCloudDb/Migrations/20231012070239_Update_Process_Maps.cs

429 lines
17 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 Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Update_Process_Maps : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_t_well_section_type_id_wellsection_type",
table: "t_process_map");
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_t_well_well_id",
table: "t_process_map");
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_wellbore_development_t_user_id_user",
table: "t_process_map_wellbore_development");
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_wellbore_development_t_well_id_well",
table: "t_process_map_wellbore_development");
migrationBuilder.DropPrimaryKey(
name: "PK_t_process_map_wellbore_development",
table: "t_process_map_wellbore_development");
migrationBuilder.DropPrimaryKey(
name: "PK_t_process_map",
table: "t_process_map");
migrationBuilder.DeleteData(
table: "t_relation_user_role_permission",
keyColumns: new[] { "id_permission", "id_user_role" },
keyValues: new object[] { 513, 1 });
migrationBuilder.DeleteData(
table: "t_relation_user_role_permission",
keyColumns: new[] { "id_permission", "id_user_role" },
keyValues: new object[] { 514, 1 });
migrationBuilder.DeleteData(
table: "t_relation_user_role_permission",
keyColumns: new[] { "id_permission", "id_user_role" },
keyValues: new object[] { 515, 1 });
migrationBuilder.DeleteData(
table: "t_permission",
keyColumn: "id",
keyValue: 513);
migrationBuilder.DeleteData(
table: "t_permission",
keyColumn: "id",
keyValue: 514);
migrationBuilder.DeleteData(
table: "t_permission",
keyColumn: "id",
keyValue: 515);
migrationBuilder.RenameTable(
name: "t_process_map_wellbore_development",
newName: "t_process_map_well_ream");
migrationBuilder.RenameTable(
name: "t_process_map",
newName: "t_process_map_well_drilling");
migrationBuilder.RenameIndex(
name: "IX_t_process_map_wellbore_development_id_well",
table: "t_process_map_well_ream",
newName: "IX_t_process_map_well_ream_id_well");
migrationBuilder.RenameIndex(
name: "IX_t_process_map_wellbore_development_id_user",
table: "t_process_map_well_ream",
newName: "IX_t_process_map_well_ream_id_user");
migrationBuilder.RenameColumn(
name: "well_id",
table: "t_process_map_well_drilling",
newName: "id_well");
migrationBuilder.RenameIndex(
name: "IX_t_process_map_well_id",
table: "t_process_map_well_drilling",
newName: "IX_t_process_map_well_drilling_id_well");
migrationBuilder.RenameIndex(
name: "IX_t_process_map_id_wellsection_type",
table: "t_process_map_well_drilling",
newName: "IX_t_process_map_well_drilling_id_wellsection_type");
migrationBuilder.AlterTable(
name: "t_process_map_well_ream",
comment: "РТК проработка скважины",
oldComment: "РТК план проработка скважины");
migrationBuilder.AlterTable(
name: "t_process_map_well_drilling",
comment: "РТК бурение скважины",
oldComment: "Операции по скважине - РТК");
migrationBuilder.AlterColumn<double>(
name: "depth_start",
table: "t_process_map_well_ream",
type: "double precision",
nullable: false,
comment: "Глубина по стволу от, м",
oldClrType: typeof(double),
oldType: "double precision",
oldComment: "Стартовая глубина, м");
migrationBuilder.AlterColumn<double>(
name: "depth_end",
table: "t_process_map_well_ream",
type: "double precision",
nullable: false,
comment: "Глубина по стволу до, м",
oldClrType: typeof(double),
oldType: "double precision",
oldComment: "Окончательная глубина, м");
migrationBuilder.AddColumn<int>(
name: "id_wellsection_type",
table: "t_process_map_well_ream",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "Тип секции");
migrationBuilder.AlterColumn<double>(
name: "depth_start",
table: "t_process_map_well_drilling",
type: "double precision",
nullable: false,
comment: "Глубина по стволу от, м",
oldClrType: typeof(double),
oldType: "double precision",
oldComment: "Стартовая глубина");
migrationBuilder.AlterColumn<double>(
name: "depth_end",
table: "t_process_map_well_drilling",
type: "double precision",
nullable: false,
comment: "Глубина по стволу до, м",
oldClrType: typeof(double),
oldType: "double precision",
oldComment: "Глубина окончания интервала");
migrationBuilder.AddColumn<string>(
name: "comment",
table: "t_process_map_well_drilling",
type: "text",
nullable: true,
comment: "Комментарий");
migrationBuilder.AddPrimaryKey(
name: "PK_t_process_map_well_ream",
table: "t_process_map_well_ream",
column: "id");
migrationBuilder.AddPrimaryKey(
name: "PK_t_process_map_well_drilling",
table: "t_process_map_well_drilling",
column: "id");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_well_ream_id_wellsection_type",
table: "t_process_map_well_ream",
column: "id_wellsection_type");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_well_drilling_id_user",
table: "t_process_map_well_drilling",
column: "id_user");
migrationBuilder.AddForeignKey(
name: "FK_t_process_map_well_drilling_t_user_id_user",
table: "t_process_map_well_drilling",
column: "id_user",
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_t_process_map_well_drilling_t_well_id_well",
table: "t_process_map_well_drilling",
column: "id_well",
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_t_process_map_well_drilling_t_well_section_type_id_wellsect~",
table: "t_process_map_well_drilling",
column: "id_wellsection_type",
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_t_process_map_well_ream_t_user_id_user",
table: "t_process_map_well_ream",
column: "id_user",
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_t_process_map_well_ream_t_well_id_well",
table: "t_process_map_well_ream",
column: "id_well",
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_t_process_map_well_ream_t_well_section_type_id_wellsection_~",
table: "t_process_map_well_ream",
column: "id_wellsection_type",
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_well_drilling_t_user_id_user",
table: "t_process_map_well_drilling");
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_well_drilling_t_well_id_well",
table: "t_process_map_well_drilling");
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_well_drilling_t_well_section_type_id_wellsect~",
table: "t_process_map_well_drilling");
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_well_ream_t_user_id_user",
table: "t_process_map_well_ream");
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_well_ream_t_well_id_well",
table: "t_process_map_well_ream");
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_well_ream_t_well_section_type_id_wellsection_~",
table: "t_process_map_well_ream");
migrationBuilder.DropPrimaryKey(
name: "PK_t_process_map_well_ream",
table: "t_process_map_well_ream");
migrationBuilder.DropIndex(
name: "IX_t_process_map_well_ream_id_wellsection_type",
table: "t_process_map_well_ream");
migrationBuilder.DropPrimaryKey(
name: "PK_t_process_map_well_drilling",
table: "t_process_map_well_drilling");
migrationBuilder.DropIndex(
name: "IX_t_process_map_well_drilling_id_user",
table: "t_process_map_well_drilling");
migrationBuilder.DropColumn(
name: "id_wellsection_type",
table: "t_process_map_well_ream");
migrationBuilder.DropColumn(
name: "comment",
table: "t_process_map_well_drilling");
migrationBuilder.RenameTable(
name: "t_process_map_well_ream",
newName: "t_process_map_wellbore_development");
migrationBuilder.RenameTable(
name: "t_process_map_well_drilling",
newName: "t_process_map");
migrationBuilder.RenameIndex(
name: "IX_t_process_map_well_ream_id_well",
table: "t_process_map_wellbore_development",
newName: "IX_t_process_map_wellbore_development_id_well");
migrationBuilder.RenameIndex(
name: "IX_t_process_map_well_ream_id_user",
table: "t_process_map_wellbore_development",
newName: "IX_t_process_map_wellbore_development_id_user");
migrationBuilder.RenameColumn(
name: "id_well",
table: "t_process_map",
newName: "well_id");
migrationBuilder.RenameIndex(
name: "IX_t_process_map_well_drilling_id_wellsection_type",
table: "t_process_map",
newName: "IX_t_process_map_id_wellsection_type");
migrationBuilder.RenameIndex(
name: "IX_t_process_map_well_drilling_id_well",
table: "t_process_map",
newName: "IX_t_process_map_well_id");
migrationBuilder.AlterTable(
name: "t_process_map_wellbore_development",
comment: "РТК план проработка скважины",
oldComment: "РТК проработка скважины");
migrationBuilder.AlterTable(
name: "t_process_map",
comment: "Операции по скважине - РТК",
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.AlterColumn<double>(
name: "depth_start",
table: "t_process_map",
type: "double precision",
nullable: false,
comment: "Стартовая глубина",
oldClrType: typeof(double),
oldType: "double precision",
oldComment: "Глубина по стволу от, м");
migrationBuilder.AlterColumn<double>(
name: "depth_end",
table: "t_process_map",
type: "double precision",
nullable: false,
comment: "Глубина окончания интервала",
oldClrType: typeof(double),
oldType: "double precision",
oldComment: "Глубина по стволу до, м");
migrationBuilder.AddPrimaryKey(
name: "PK_t_process_map_wellbore_development",
table: "t_process_map_wellbore_development",
column: "id");
migrationBuilder.AddPrimaryKey(
name: "PK_t_process_map",
table: "t_process_map",
column: "id");
migrationBuilder.InsertData(
table: "t_permission",
columns: new[] { "id", "description", "name" },
values: new object[,]
{
{ 513, "Разрешение просматривать РТК", "ProcessMap.get" },
{ 514, "Разрешение редактировать РТК", "ProcessMap.edit" },
{ 515, "Разрешение удалять РТК", "ProcessMap.delete" }
});
migrationBuilder.InsertData(
table: "t_relation_user_role_permission",
columns: new[] { "id_permission", "id_user_role" },
values: new object[,]
{
{ 513, 1 },
{ 514, 1 },
{ 515, 1 }
});
migrationBuilder.AddForeignKey(
name: "FK_t_process_map_t_well_section_type_id_wellsection_type",
table: "t_process_map",
column: "id_wellsection_type",
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_t_process_map_t_well_well_id",
table: "t_process_map",
column: "well_id",
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
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);
migrationBuilder.AddForeignKey(
name: "FK_t_process_map_wellbore_development_t_well_id_well",
table: "t_process_map_wellbore_development",
column: "id_well",
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
}
}