#649 Добавить партиционирование #16
@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace DD.Persistence.Database.Postgres.Migrations
|
namespace DD.Persistence.Database.Postgres.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(PersistencePostgresContext))]
|
[DbContext(typeof(PersistencePostgresContext))]
|
||||||
[Migration("20241220062251_Init")]
|
[Migration("20241226122220_Init")]
|
||||||
partial class Init
|
partial class Init
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -20,7 +20,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
.HasAnnotation("ProductVersion", "9.0.0")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
@ -43,7 +43,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("SystemId");
|
b.HasKey("SystemId");
|
||||||
|
|
||||||
b.ToTable("DataSourceSystem");
|
b.ToTable("data_source_system");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
|
||||||
@ -67,7 +67,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("DiscriminatorId", "ParameterId", "Timestamp");
|
b.HasKey("DiscriminatorId", "ParameterId", "Timestamp");
|
||||||
|
|
||||||
b.ToTable("ParameterData");
|
b.ToTable("parameter_data");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
||||||
@ -102,7 +102,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasIndex("SystemId");
|
b.HasIndex("SystemId");
|
||||||
|
|
||||||
b.ToTable("TechMessage");
|
b.ToTable("tech_message");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b =>
|
||||||
@ -122,7 +122,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("IdDiscriminator", "Timestamp");
|
b.HasKey("IdDiscriminator", "Timestamp");
|
||||||
|
|
||||||
b.ToTable("TimestampedSets", t =>
|
b.ToTable("timestamped_set", t =>
|
||||||
{
|
{
|
||||||
t.HasComment("Общая таблица данных временных рядов");
|
t.HasComment("Общая таблица данных временных рядов");
|
||||||
});
|
});
|
||||||
@ -178,7 +178,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("ChangeLog");
|
b.ToTable("change_log");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b =>
|
||||||
@ -261,7 +261,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Date");
|
b.HasKey("Date");
|
||||||
|
|
||||||
b.ToTable("DataSaub");
|
b.ToTable("data_saub");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b =>
|
||||||
@ -285,7 +285,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Key", "Created");
|
b.HasKey("Key", "Created");
|
||||||
|
|
||||||
b.ToTable("Setpoint");
|
b.ToTable("setpoint");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
@ -12,7 +12,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "ChangeLog",
|
name: "change_log",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ записи"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ записи"),
|
||||||
@ -29,11 +29,11 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_ChangeLog", x => x.Id);
|
table.PrimaryKey("PK_change_log", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "DataSaub",
|
name: "data_saub",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
@ -58,11 +58,11 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_DataSaub", x => x.date);
|
table.PrimaryKey("PK_data_saub", x => x.date);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "DataSourceSystem",
|
name: "data_source_system",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
SystemId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id системы - источника данных"),
|
SystemId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id системы - источника данных"),
|
||||||
@ -71,11 +71,11 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_DataSourceSystem", x => x.SystemId);
|
table.PrimaryKey("PK_data_source_system", x => x.SystemId);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "ParameterData",
|
name: "parameter_data",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
DiscriminatorId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор системы"),
|
DiscriminatorId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор системы"),
|
||||||
@ -85,11 +85,11 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_ParameterData", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp });
|
table.PrimaryKey("PK_parameter_data", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp });
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Setpoint",
|
name: "setpoint",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Key = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ"),
|
Key = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ"),
|
||||||
@ -99,11 +99,11 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Setpoint", x => new { x.Key, x.Created });
|
table.PrimaryKey("PK_setpoint", x => new { x.Key, x.Created });
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "TimestampedSets",
|
name: "timestamped_set",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
IdDiscriminator = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор ссылка на тип сохраняемых данных"),
|
IdDiscriminator = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор ссылка на тип сохраняемых данных"),
|
||||||
@ -112,12 +112,12 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_TimestampedSets", x => new { x.IdDiscriminator, x.Timestamp });
|
table.PrimaryKey("PK_timestamped_set", x => new { x.IdDiscriminator, x.Timestamp });
|
||||||
},
|
},
|
||||||
comment: "Общая таблица данных временных рядов");
|
comment: "Общая таблица данных временных рядов");
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "TechMessage",
|
name: "tech_message",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
EventId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id события"),
|
EventId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id события"),
|
||||||
@ -129,44 +129,47 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_TechMessage", x => x.EventId);
|
table.PrimaryKey("PK_tech_message", x => x.EventId);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_TechMessage_DataSourceSystem_SystemId",
|
name: "FK_tech_message_data_source_system_SystemId",
|
||||||
column: x => x.SystemId,
|
column: x => x.SystemId,
|
||||||
principalTable: "DataSourceSystem",
|
principalTable: "data_source_system",
|
||||||
principalColumn: "SystemId",
|
principalColumn: "SystemId",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_TechMessage_SystemId",
|
name: "IX_tech_message_SystemId",
|
||||||
table: "TechMessage",
|
table: "tech_message",
|
||||||
column: "SystemId");
|
column: "SystemId");
|
||||||
|
|
||||||
|
migrationBuilder.Sql
|
||||||
|
("SELECT create_hypertable('parameter_data','Timestamp','ParameterId',2,chunk_time_interval => INTERVAL '5 day');");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "ChangeLog");
|
name: "change_log");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "DataSaub");
|
name: "data_saub");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "ParameterData");
|
name: "parameter_data");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Setpoint");
|
name: "setpoint");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "TechMessage");
|
name: "tech_message");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "TimestampedSets");
|
name: "timestamped_set");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "DataSourceSystem");
|
name: "data_source_system");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
.HasAnnotation("ProductVersion", "9.0.0")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
@ -40,7 +40,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("SystemId");
|
b.HasKey("SystemId");
|
||||||
|
|
||||||
b.ToTable("DataSourceSystem");
|
b.ToTable("data_source_system");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
|
||||||
@ -64,7 +64,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("DiscriminatorId", "ParameterId", "Timestamp");
|
b.HasKey("DiscriminatorId", "ParameterId", "Timestamp");
|
||||||
|
|
||||||
b.ToTable("ParameterData");
|
b.ToTable("parameter_data");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
||||||
@ -99,7 +99,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasIndex("SystemId");
|
b.HasIndex("SystemId");
|
||||||
|
|
||||||
b.ToTable("TechMessage");
|
b.ToTable("tech_message");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b =>
|
||||||
@ -119,7 +119,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("IdDiscriminator", "Timestamp");
|
b.HasKey("IdDiscriminator", "Timestamp");
|
||||||
|
|
||||||
b.ToTable("TimestampedSets", t =>
|
b.ToTable("timestamped_set", t =>
|
||||||
{
|
{
|
||||||
t.HasComment("Общая таблица данных временных рядов");
|
t.HasComment("Общая таблица данных временных рядов");
|
||||||
});
|
});
|
||||||
@ -175,7 +175,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("ChangeLog");
|
b.ToTable("change_log");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b =>
|
||||||
@ -258,7 +258,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Date");
|
b.HasKey("Date");
|
||||||
|
|
||||||
b.ToTable("DataSaub");
|
b.ToTable("data_saub");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b =>
|
||||||
@ -282,7 +282,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Key", "Created");
|
b.HasKey("Key", "Created");
|
||||||
|
|
||||||
b.ToTable("Setpoint");
|
b.ToTable("setpoint");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
||||||
|
@ -9,6 +9,7 @@ namespace DD.Persistence.Database.Model;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Часть записи, описывающая изменение
|
/// Часть записи, описывающая изменение
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Table("change_log")]
|
||||||
public class ChangeLog : IChangeLog, IWithSectionPart
|
public class ChangeLog : IChangeLog, IWithSectionPart
|
||||||
{
|
{
|
||||||
[Key, Comment("Ключ записи")]
|
[Key, Comment("Ключ записи")]
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Model;
|
namespace DD.Persistence.Database.Model;
|
||||||
|
|
||||||
|
[Table("data_saub")]
|
||||||
public class DataSaub : ITimestampedData
|
public class DataSaub : ITimestampedData
|
||||||
{
|
{
|
||||||
[Key, Column("date")]
|
[Key, Column("date")]
|
||||||
|
@ -3,6 +3,8 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Entity;
|
namespace DD.Persistence.Database.Entity;
|
||||||
|
|
||||||
|
[Table("data_source_system")]
|
||||||
public class DataSourceSystem
|
public class DataSourceSystem
|
||||||
{
|
{
|
||||||
[Key, Comment("Id системы - источника данных")]
|
[Key, Comment("Id системы - источника данных")]
|
||||||
|
@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
|
|
||||||
namespace DD.Persistence.Database.Entity;
|
namespace DD.Persistence.Database.Entity;
|
||||||
|
|
||||||
|
[Table("parameter_data")]
|
||||||
[PrimaryKey(nameof(DiscriminatorId), nameof(ParameterId), nameof(Timestamp))]
|
[PrimaryKey(nameof(DiscriminatorId), nameof(ParameterId), nameof(Timestamp))]
|
||||||
public class ParameterData
|
public class ParameterData
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
|
|
||||||
namespace DD.Persistence.Database.Model
|
namespace DD.Persistence.Database.Model
|
||||||
{
|
{
|
||||||
|
[Table("setpoint")]
|
||||||
[PrimaryKey(nameof(Key), nameof(Created))]
|
[PrimaryKey(nameof(Key), nameof(Created))]
|
||||||
public class Setpoint
|
public class Setpoint
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
|
|
||||||
namespace DD.Persistence.Database.Entity
|
namespace DD.Persistence.Database.Entity
|
||||||
{
|
{
|
||||||
|
[Table("tech_message")]
|
||||||
public class TechMessage
|
public class TechMessage
|
||||||
{
|
{
|
||||||
[Key, Comment("Id события")]
|
[Key, Comment("Id события")]
|
||||||
|
@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
|
|
||||||
namespace DD.Persistence.Database.Entity;
|
namespace DD.Persistence.Database.Entity;
|
||||||
|
|
||||||
|
[Table("timestamped_set")]
|
||||||
[Comment("Общая таблица данных временных рядов")]
|
[Comment("Общая таблица данных временных рядов")]
|
||||||
[PrimaryKey(nameof(IdDiscriminator), nameof(Timestamp))]
|
[PrimaryKey(nameof(IdDiscriminator), nameof(Timestamp))]
|
||||||
public record TimestampedSet(
|
public record TimestampedSet(
|
||||||
|
Loading…
Reference in New Issue
Block a user