DD.WellWorkover.Cloud/AsbCloudDb/Migrations/20230327205436_add_table_wits_gtr.cs
2023-03-28 02:21:56 +05:00

140 lines
6.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<int>(type: "integer", nullable: false),
id_record = table.Column<int>(type: "integer", nullable: false),
id_item = table.Column<int>(type: "integer", nullable: false),
date = table.Column<DateTimeOffset>(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<int>(type: "integer", nullable: false),
id_record = table.Column<int>(type: "integer", nullable: false),
id_item = table.Column<int>(type: "integer", nullable: false),
value = table.Column<float>(type: "real", nullable: true),
TelemetryId = table.Column<int>(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<int>(type: "integer", nullable: false),
id_record = table.Column<int>(type: "integer", nullable: false),
id_item = table.Column<int>(type: "integer", nullable: false),
Value = table.Column<long>(type: "bigint", nullable: true),
TelemetryId = table.Column<int>(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<int>(type: "integer", nullable: false),
id_record = table.Column<int>(type: "integer", nullable: false),
id_item = table.Column<int>(type: "integer", nullable: false),
value = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
TelemetryId = table.Column<int>(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");
}
}
}