using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace AsbCloudDb.Migrations
{
    public partial class AddTable_PlannedTrajectory : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "t_planned_trajectory",
                columns: table => new
                {
                    id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    id_user = table.Column<int>(type: "integer", nullable: false, comment: "ID пользователя который внес/изменил запись"),
                    id_well = table.Column<int>(type: "integer", nullable: false, comment: "ID скважины"),
                    load_date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата загрузки траектории"),
                    wellbore_depth = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина по стволу"),
                    zenith_angle = table.Column<double>(type: "double precision", nullable: false, comment: "Угол зенитный"),
                    azimuth_geo = table.Column<double>(type: "double precision", nullable: false, comment: "Азимут Географ."),
                    azimuth_magnetic = table.Column<double>(type: "double precision", nullable: false, comment: "Азимут Магнитный"),
                    vertical_depth = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина вертикальная"),
                    absolute_mark = table.Column<double>(type: "double precision", nullable: false, comment: "Абсолютная отметка"),
                    north_orifice = table.Column<double>(type: "double precision", nullable: false, comment: "Север отн-но устья"),
                    east_orifice = table.Column<double>(type: "double precision", nullable: false, comment: "Восток отн-но устья"),
                    east_cartographic = table.Column<double>(type: "double precision", nullable: false, comment: "Восток картографический"),
                    north_cartographic = table.Column<double>(type: "double precision", nullable: false, comment: "Север картографический"),
                    spatial_intensity = table.Column<double>(type: "double precision", nullable: false, comment: "Пространственная интенсивность"),
                    angle_intensity = table.Column<double>(type: "double precision", nullable: false, comment: "Интенсивность по углу"),
                    azimuth_intensity = table.Column<double>(type: "double precision", nullable: false, comment: "Интенсивность по азимуту"),
                    orifice_offset = table.Column<double>(type: "double precision", nullable: false, comment: "Смещение от устья"),
                    comment = table.Column<string>(type: "text", nullable: true, comment: "Комментарии")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_planned_trajectory", x => x.id);
                    table.ForeignKey(
                        name: "FK_t_planned_trajectory_t_user_id_user",
                        column: x => x.id_user,
                        principalTable: "t_user",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_t_planned_trajectory_t_well_id_well",
                        column: x => x.id_well,
                        principalTable: "t_well",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "Загрузка плановой траектории");

            migrationBuilder.CreateIndex(
                name: "IX_t_planned_trajectory_id_user",
                table: "t_planned_trajectory",
                column: "id_user");

            migrationBuilder.CreateIndex(
                name: "IX_t_planned_trajectory_id_well",
                table: "t_planned_trajectory",
                column: "id_well");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "t_planned_trajectory");
        }
    }
}