forked from ddrilling/AsbCloudServer
work migration (timescale)
This commit is contained in:
parent
8e663e7bef
commit
2e58dea88a
@ -34,8 +34,6 @@ namespace AsbCloudApp.Repositories
|
||||
Task<IEnumerable<WitsRecordDto>> GetAsync(int idWell,
|
||||
DateTime dateBegin = default, double intervalSec = 600d,
|
||||
int approxPointsCount = 1024, CancellationToken token = default);
|
||||
|
||||
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
[DbContext(typeof(AsbCloudDbContext))]
|
||||
[Migration("20230331060526_add_table_WITS_GTR_and_manual_hypertable")]
|
||||
partial class add_table_WITS_GTR_and_manual_hypertable
|
||||
[Migration("20230407125505_add_table_wits_and_manual_hypertable")]
|
||||
partial class add_table_wits_and_manual_hypertable
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -150,8 +150,8 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("id_well")
|
||||
.HasComment("ID скважины");
|
||||
|
||||
b.Property<DateTimeOffset>("StartDate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
b.Property<DateOnly>("StartDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("start_date")
|
||||
.HasComment("Дата отчёта");
|
||||
|
||||
@ -803,7 +803,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasComment("Действия с файлами.");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsFloat", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemFloat", b =>
|
||||
{
|
||||
b.Property<int>("IdTelemetry")
|
||||
.HasColumnType("integer")
|
||||
@ -825,14 +825,14 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("Value");
|
||||
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
|
||||
|
||||
b.ToTable("t_wits_float");
|
||||
|
||||
b.HasComment("таблица данных ГТИ с типом значения float");
|
||||
b.HasComment("таблица данных ГТИ с типом значения ");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsInt", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemInt", b =>
|
||||
{
|
||||
b.Property<int>("IdTelemetry")
|
||||
.HasColumnType("integer")
|
||||
@ -854,14 +854,14 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("Value");
|
||||
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
|
||||
|
||||
b.ToTable("t_wits_int");
|
||||
|
||||
b.HasComment("таблица данных ГТИ с типом значения int16 int32");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsStr", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemString", b =>
|
||||
{
|
||||
b.Property<int>("IdTelemetry")
|
||||
.HasColumnType("integer")
|
||||
@ -880,10 +880,11 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("date");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("Value");
|
||||
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
|
||||
|
||||
b.ToTable("t_wits_string");
|
||||
|
||||
@ -7232,7 +7233,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsFloat", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemFloat", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany()
|
||||
@ -7243,7 +7244,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("Telemetry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsInt", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemInt", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany()
|
||||
@ -7254,7 +7255,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("Telemetry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsStr", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemString", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany()
|
@ -5,10 +5,20 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class add_table_WITS_GTR_and_manual_hypertable : Migration
|
||||
public partial class add_table_wits_and_manual_hypertable : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<DateOnly>(
|
||||
name: "start_date",
|
||||
table: "t_daily_report",
|
||||
type: "date",
|
||||
nullable: false,
|
||||
comment: "Дата отчёта",
|
||||
oldClrType: typeof(DateTimeOffset),
|
||||
oldType: "timestamp with time zone",
|
||||
oldComment: "Дата отчёта");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "t_wits_float",
|
||||
columns: table => new
|
||||
@ -21,7 +31,7 @@ namespace AsbCloudDb.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_t_wits_float", x => new { x.id_telemetry, x.id_record, x.id_item });
|
||||
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,
|
||||
@ -29,7 +39,7 @@ namespace AsbCloudDb.Migrations
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
},
|
||||
comment: "таблица данных ГТИ с типом значения float");
|
||||
comment: "таблица данных ГТИ с типом значения ");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "t_wits_int",
|
||||
@ -43,7 +53,7 @@ namespace AsbCloudDb.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_t_wits_int", x => new { x.id_telemetry, x.id_record, x.id_item });
|
||||
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,
|
||||
@ -61,11 +71,11 @@ namespace AsbCloudDb.Migrations
|
||||
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: true)
|
||||
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 });
|
||||
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,
|
||||
@ -74,10 +84,12 @@ namespace AsbCloudDb.Migrations
|
||||
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'); ");
|
||||
|
||||
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)
|
||||
@ -90,6 +102,16 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "t_wits_string");
|
||||
|
||||
migrationBuilder.AlterColumn<DateTimeOffset>(
|
||||
name: "start_date",
|
||||
table: "t_daily_report",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
comment: "Дата отчёта",
|
||||
oldClrType: typeof(DateOnly),
|
||||
oldType: "date",
|
||||
oldComment: "Дата отчёта");
|
||||
}
|
||||
}
|
||||
}
|
@ -801,7 +801,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.HasComment("Действия с файлами.");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsFloat", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemFloat", b =>
|
||||
{
|
||||
b.Property<int>("IdTelemetry")
|
||||
.HasColumnType("integer")
|
||||
@ -823,14 +823,14 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnType("real")
|
||||
.HasColumnName("Value");
|
||||
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
|
||||
|
||||
b.ToTable("t_wits_float");
|
||||
|
||||
b.HasComment("таблица данных ГТИ с типом значения float");
|
||||
b.HasComment("таблица данных ГТИ с типом значения ");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsInt", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemInt", b =>
|
||||
{
|
||||
b.Property<int>("IdTelemetry")
|
||||
.HasColumnType("integer")
|
||||
@ -852,14 +852,14 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("Value");
|
||||
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
|
||||
|
||||
b.ToTable("t_wits_int");
|
||||
|
||||
b.HasComment("таблица данных ГТИ с типом значения int16 int32");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsStr", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemString", b =>
|
||||
{
|
||||
b.Property<int>("IdTelemetry")
|
||||
.HasColumnType("integer")
|
||||
@ -878,10 +878,11 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("date");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("Value");
|
||||
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem", "DateTime");
|
||||
|
||||
b.ToTable("t_wits_string");
|
||||
|
||||
@ -7230,7 +7231,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsFloat", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemFloat", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany()
|
||||
@ -7241,7 +7242,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("Telemetry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsInt", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemInt", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany()
|
||||
@ -7252,7 +7253,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("Telemetry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsStr", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.GTR.WitsItemString", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||
.WithMany()
|
||||
|
@ -345,21 +345,24 @@ namespace AsbCloudDb.Model
|
||||
entity.HasKey(
|
||||
nameof(ITelemetryData.IdTelemetry),
|
||||
nameof(WitsItemBase<float>.IdRecord),
|
||||
nameof(WitsItemBase<float>.IdItem));
|
||||
});
|
||||
nameof(WitsItemBase<float>.IdItem),
|
||||
nameof(WitsItemBase<float>.DateTime));
|
||||
});
|
||||
modelBuilder.Entity<WitsItemInt>(entity =>
|
||||
{
|
||||
entity.HasKey(
|
||||
nameof(ITelemetryData.IdTelemetry),
|
||||
nameof(WitsItemBase<int>.IdRecord),
|
||||
nameof(WitsItemBase<int>.IdItem));
|
||||
nameof(WitsItemBase<int>.IdItem),
|
||||
nameof(WitsItemBase<int>.DateTime));
|
||||
});
|
||||
modelBuilder.Entity<WitsItemString>(entity =>
|
||||
{
|
||||
entity.HasKey(
|
||||
nameof(ITelemetryData.IdTelemetry),
|
||||
nameof(WitsItemBase<string>.IdRecord),
|
||||
nameof(WitsItemBase<string>.IdItem));
|
||||
nameof(WitsItemBase<string>.IdItem),
|
||||
nameof(WitsItemBase<string>.DateTime));
|
||||
});
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace AsbCloudDb.Model.GTR
|
||||
public DateTimeOffset DateTime { get; set; }
|
||||
|
||||
[Column("Value")]
|
||||
public T? Value { get; set; }
|
||||
public T Value { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdTelemetry))]
|
||||
public virtual Telemetry? Telemetry { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user