DD.WellWorkover.Cloud/AsbCloudDb/Migrations/20230413200953_add_table_wits_and_manualHypertable.cs

97 lines
4.6 KiB
C#
Raw Normal View History

2023-04-14 01:10:58 +05:00
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class add_table_wits_and_manualHypertable : Migration
{
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);
},
comment: "таблица данных ГТИ с типом значения ");
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);
},
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),
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");
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'); ");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_wits_float");
migrationBuilder.DropTable(
name: "t_wits_int");
migrationBuilder.DropTable(
name: "t_wits_string");
}
}
}