forked from ddrilling/AsbCloudServer
105 lines
5.1 KiB
C#
105 lines
5.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace AsbCloudDb.Migrations
|
|
{
|
|
public partial class Add_Table_Subsystem_and_SubsystemOperationTime : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "t_subsystem",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
|
description = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_t_subsystem", x => x.id);
|
|
},
|
|
comment: "Описание подсистем");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "t_subsystem_operation_time",
|
|
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, comment: "ИД телеметрии по которой выдается информация"),
|
|
id_subsystem = table.Column<int>(type: "integer", nullable: false),
|
|
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<float>(type: "real", nullable: true, comment: "глубина забоя на момент включения подсистемы"),
|
|
depth_end = table.Column<float>(type: "real", nullable: true, comment: "глубина забоя на момент выключения подсистемы")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_t_subsystem_operation_time", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_t_subsystem_operation_time_t_subsystem_id_subsystem",
|
|
column: x => x.id_subsystem,
|
|
principalTable: "t_subsystem",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_t_subsystem_operation_time_t_telemetry_id_telemetry",
|
|
column: x => x.id_telemetry,
|
|
principalTable: "t_telemetry",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
},
|
|
comment: "наработки подсистем");
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "t_permission",
|
|
columns: new[] { "id", "description", "name" },
|
|
values: new object[,]
|
|
{
|
|
{ 127, "Разрешение удалять админ. Подсистемы", "AdminSubsytem.delete" },
|
|
{ 128, "Разрешение редактировать админ. Подсистемы", "AdminSubsytem.edit" },
|
|
{ 129, "Разрешение просматривать админ. Подсистемы", "AdminSubsytem.get" }
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_t_subsystem_operation_time_id_subsystem",
|
|
table: "t_subsystem_operation_time",
|
|
column: "id_subsystem");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_t_subsystem_operation_time_id_telemetry",
|
|
table: "t_subsystem_operation_time",
|
|
column: "id_telemetry");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "t_subsystem_operation_time");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "t_subsystem");
|
|
|
|
migrationBuilder.DeleteData(
|
|
table: "t_permission",
|
|
keyColumn: "id",
|
|
keyValue: 127);
|
|
|
|
migrationBuilder.DeleteData(
|
|
table: "t_permission",
|
|
keyColumn: "id",
|
|
keyValue: 128);
|
|
|
|
migrationBuilder.DeleteData(
|
|
table: "t_permission",
|
|
keyColumn: "id",
|
|
keyValue: 129);
|
|
}
|
|
}
|
|
}
|