using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace AsbCloudDb.Migrations { public partial class add_table_wits_gtr : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "t_wits_base", columns: table => new { id_telemetry = table.Column(type: "integer", nullable: false), id_record = table.Column(type: "integer", nullable: false), id_item = table.Column(type: "integer", nullable: false), date = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_t_wits_base", x => new { x.id_telemetry, x.id_record, x.id_item }); }, comment: "таблица данных ГТИ"); migrationBuilder.CreateTable( name: "t_wits_float", columns: table => new { id_telemetry = table.Column(type: "integer", nullable: false), id_record = table.Column(type: "integer", nullable: false), id_item = table.Column(type: "integer", nullable: false), value = table.Column(type: "real", nullable: true), TelemetryId = table.Column(type: "integer", nullable: true) }, constraints: table => { table.PrimaryKey("PK_t_wits_float", x => new { x.id_telemetry, x.id_record, x.id_item }); table.ForeignKey( name: "FK_t_wits_float_t_telemetry_TelemetryId", column: x => x.TelemetryId, principalTable: "t_telemetry", principalColumn: "id"); table.ForeignKey( name: "FK_t_wits_float_t_wits_base_id_telemetry_id_record_id_item", columns: x => new { x.id_telemetry, x.id_record, x.id_item }, principalTable: "t_wits_base", principalColumns: new[] { "id_telemetry", "id_record", "id_item" }, onDelete: ReferentialAction.Cascade); }, comment: "таблица данных ГТИ с типом значения float"); migrationBuilder.CreateTable( name: "t_wits_int", columns: table => new { id_telemetry = table.Column(type: "integer", nullable: false), id_record = table.Column(type: "integer", nullable: false), id_item = table.Column(type: "integer", nullable: false), Value = table.Column(type: "bigint", nullable: true), TelemetryId = table.Column(type: "integer", nullable: true) }, constraints: table => { table.PrimaryKey("PK_t_wits_int", x => new { x.id_telemetry, x.id_record, x.id_item }); table.ForeignKey( name: "FK_t_wits_int_t_telemetry_TelemetryId", column: x => x.TelemetryId, principalTable: "t_telemetry", principalColumn: "id"); table.ForeignKey( name: "FK_t_wits_int_t_wits_base_id_telemetry_id_record_id_item", columns: x => new { x.id_telemetry, x.id_record, x.id_item }, principalTable: "t_wits_base", principalColumns: new[] { "id_telemetry", "id_record", "id_item" }, onDelete: ReferentialAction.Cascade); }, comment: "таблица данных ГТИ с типом значения int16 int32"); migrationBuilder.CreateTable( name: "t_wits_string", columns: table => new { id_telemetry = table.Column(type: "integer", nullable: false), id_record = table.Column(type: "integer", nullable: false), id_item = table.Column(type: "integer", nullable: false), value = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), TelemetryId = table.Column(type: "integer", nullable: true) }, constraints: table => { table.PrimaryKey("PK_t_wits_string", x => new { x.id_telemetry, x.id_record, x.id_item }); table.ForeignKey( name: "FK_t_wits_string_t_telemetry_TelemetryId", column: x => x.TelemetryId, principalTable: "t_telemetry", principalColumn: "id"); table.ForeignKey( name: "FK_t_wits_string_t_wits_base_id_telemetry_id_record_id_item", columns: x => new { x.id_telemetry, x.id_record, x.id_item }, principalTable: "t_wits_base", principalColumns: new[] { "id_telemetry", "id_record", "id_item" }, onDelete: ReferentialAction.Cascade); }, comment: "таблица данных ГТИ с типом значения string"); migrationBuilder.CreateIndex( name: "IX_t_wits_float_TelemetryId", table: "t_wits_float", column: "TelemetryId"); migrationBuilder.CreateIndex( name: "IX_t_wits_int_TelemetryId", table: "t_wits_int", column: "TelemetryId"); migrationBuilder.CreateIndex( name: "IX_t_wits_string_TelemetryId", table: "t_wits_string", column: "TelemetryId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "t_wits_float"); migrationBuilder.DropTable( name: "t_wits_int"); migrationBuilder.DropTable( name: "t_wits_string"); migrationBuilder.DropTable( name: "t_wits_base"); } } }