DD.WellWorkover.Cloud/AsbCloudDb/Migrations/20231204094830_Add_WellSectionPlan.cs

102 lines
4.8 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Add_WellSectionPlan : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_well_section_plan",
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 скважины"),
id_section_type = table.Column<int>(type: "integer", nullable: false, comment: "Тип секции"),
id_user = table.Column<int>(type: "integer", nullable: false, comment: "Id пользователя"),
date_last_update = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true, comment: "Дата последнего обновления"),
depth_start = table.Column<double>(type: "double precision", nullable: false, comment: "Начальная глубина бурения, м"),
depth_end = table.Column<double>(type: "double precision", nullable: false, comment: "Конечная глубина бурения, м"),
outer_diameter = table.Column<double>(type: "double precision", nullable: true, comment: "Внешний диаметр"),
inner_diameter = table.Column<double>(type: "double precision", nullable: true, comment: "Внутренний диаметр")
},
constraints: table =>
{
table.PrimaryKey("PK_t_well_section_plan", x => x.id);
table.ForeignKey(
name: "FK_t_well_section_plan_t_well_id_well",
column: x => x.id_well,
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_well_section_plan_t_well_section_type_id_section_type",
column: x => x.id_section_type,
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "t_permission",
columns: new[] { "id", "description", "name" },
values: new object[,]
{
{ 530, "Разрешение на редактирование плановой конструкции скважины", "WellSectionPlan.edit" },
{ 531, "Разрешение на удаление плановой конструкции скважины", "WellSectionPlan.delete" }
});
migrationBuilder.InsertData(
table: "t_relation_user_role_permission",
columns: new[] { "id_permission", "id_user_role" },
values: new object[,]
{
{ 530, 1 },
{ 531, 1 }
});
migrationBuilder.CreateIndex(
name: "IX_t_well_section_plan_id_section_type",
table: "t_well_section_plan",
column: "id_section_type");
migrationBuilder.CreateIndex(
name: "IX_t_well_section_plan_id_well_id_section_type",
table: "t_well_section_plan",
columns: new[] { "id_well", "id_section_type" },
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_well_section_plan");
migrationBuilder.DeleteData(
table: "t_relation_user_role_permission",
keyColumns: new[] { "id_permission", "id_user_role" },
keyValues: new object[] { 530, 1 });
migrationBuilder.DeleteData(
table: "t_relation_user_role_permission",
keyColumns: new[] { "id_permission", "id_user_role" },
keyValues: new object[] { 531, 1 });
migrationBuilder.DeleteData(
table: "t_permission",
keyColumn: "id",
keyValue: 530);
migrationBuilder.DeleteData(
table: "t_permission",
keyColumn: "id",
keyValue: 531);
}
}
}