DD.WellWorkover.Cloud/AsbCloudDb/Migrations/20220425110530_Add_DetectedOperations.cs

63 lines
3.3 KiB
C#
Raw Normal View History

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Add_DetectedOperations : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_detected_operation",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
id_telemetry = table.Column<int>(type: "integer", nullable: false),
id_category = table.Column<int>(type: "integer", nullable: false, comment: "Id категории операции"),
id_user = table.Column<int>(type: "integer", nullable: false, comment: "Id пользователя по телеметрии на момент начала операции"),
date_start = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата начала операции"),
date_end = 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: "Глубина после завершения операции, м")
},
constraints: table =>
{
table.PrimaryKey("PK_t_detected_operation", x => x.id);
table.ForeignKey(
name: "FK_t_detected_operation_t_telemetry_id_telemetry",
column: x => x.id_telemetry,
principalTable: "t_telemetry",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_detected_operation_t_well_operation_category_id_category",
column: x => x.id_category,
principalTable: "t_well_operation_category",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "автоматически определенные операции по телеметрии");
migrationBuilder.CreateIndex(
name: "IX_t_detected_operation_id_category",
table: "t_detected_operation",
column: "id_category");
migrationBuilder.CreateIndex(
name: "IX_t_detected_operation_id_telemetry",
table: "t_detected_operation",
column: "id_telemetry");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_detected_operation");
}
}
}