2024-07-04 11:02:45 +05:00
|
|
|
|
using System;
|
2023-04-17 18:12:11 +05:00
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudDb.Migrations
|
|
|
|
|
{
|
2023-04-18 16:07:29 +05:00
|
|
|
|
public partial class Add_GTR : Migration
|
2023-04-17 18:12:11 +05:00
|
|
|
|
{
|
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
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),
|
|
|
|
|
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
|
|
|
value = table.Column<float>(type: "real", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_t_wits_float", x => new { x.id_telemetry, x.id_record, x.id_item, x.date });
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_t_wits_float_t_telemetry_id_telemetry",
|
|
|
|
|
column: x => x.id_telemetry,
|
|
|
|
|
principalTable: "t_telemetry",
|
|
|
|
|
principalColumn: "id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
},
|
2023-04-18 16:07:29 +05:00
|
|
|
|
comment: "таблица данных ГТИ с типом значения float");
|
2023-04-17 18:12:11 +05:00
|
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
|
|
|
value = table.Column<int>(type: "integer", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_t_wits_int", x => new { x.id_telemetry, x.id_record, x.id_item, x.date });
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_t_wits_int_t_telemetry_id_telemetry",
|
|
|
|
|
column: x => x.id_telemetry,
|
|
|
|
|
principalTable: "t_telemetry",
|
|
|
|
|
principalColumn: "id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
},
|
2023-04-18 16:07:29 +05:00
|
|
|
|
comment: "таблица данных ГТИ с типом значения int");
|
2023-04-17 18:12:11 +05:00
|
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
|
|
|
value = table.Column<string>(type: "text", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_t_wits_string", x => new { x.id_telemetry, x.id_record, x.id_item, x.date });
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_t_wits_string_t_telemetry_id_telemetry",
|
|
|
|
|
column: x => x.id_telemetry,
|
|
|
|
|
principalTable: "t_telemetry",
|
|
|
|
|
principalColumn: "id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
},
|
|
|
|
|
comment: "таблица данных ГТИ с типом значения string");
|
2023-04-18 16:07:29 +05:00
|
|
|
|
|
|
|
|
|
migrationBuilder.Sql
|
|
|
|
|
("SELECT create_hypertable('t_wits_string','date','id_telemetry',2,chunk_time_interval => INTERVAL '5 day'); " +
|
|
|
|
|
"SELECT create_hypertable('t_wits_float','date','id_telemetry',2,chunk_time_interval => INTERVAL '5 day'); " +
|
|
|
|
|
"SELECT create_hypertable('t_wits_int','date','id_telemetry',2,chunk_time_interval => INTERVAL '5 day'); ");
|
|
|
|
|
|
2023-04-17 18:12:11 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "t_wits_float");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "t_wits_int");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "t_wits_string");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|