using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace AsbCloudDb.Migrations { public partial class Update_Subsystems : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "t_subsystem_operation_time"); migrationBuilder.DeleteData( table: "t_subsystem", keyColumn: "id", keyValue: 2); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "t_subsystem_operation_time", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), id_subsystem = table.Column(type: "integer", nullable: false), id_telemetry = table.Column(type: "integer", nullable: false, comment: "ИД телеметрии по которой выдается информация"), date_end = table.Column(type: "timestamp with time zone", nullable: false, comment: "дата/время выключения подсистемы"), date_start = table.Column(type: "timestamp with time zone", nullable: false, comment: "дата/время включения подсистемы"), depth_end = table.Column(type: "real", nullable: true, comment: "глубина забоя на момент выключения подсистемы"), depth_start = table.Column(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_subsystem", columns: new[] { "id", "description", "name" }, values: new object[] { 2, "Алгоритм поиска оптимальных параметров бурения САУБ", "MSE" }); 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"); } } }