diff --git a/DD.Persistence.App/appsettings.Tests.json b/DD.Persistence.App/appsettings.Tests.json index 72c43d3..e8d3cc4 100644 --- a/DD.Persistence.App/appsettings.Tests.json +++ b/DD.Persistence.App/appsettings.Tests.json @@ -1,10 +1,10 @@ { "DbConnection": { - "Host": "postgres", + "Host": "localhost", "Port": 5432, "Database": "persistence", "Username": "postgres", - "Password": "postgres" + "Password": "q" }, "NeedUseKeyCloak": false, "AuthUser": { diff --git a/DD.Persistence.Benchmark/DD.Persistence.Benchmark.csproj b/DD.Persistence.Benchmark/DD.Persistence.Benchmark.csproj index 87bb221..568dc7e 100644 --- a/DD.Persistence.Benchmark/DD.Persistence.Benchmark.csproj +++ b/DD.Persistence.Benchmark/DD.Persistence.Benchmark.csproj @@ -8,7 +8,7 @@ - + diff --git a/DD.Persistence.Benchmark/Tests/WitsDataBenchmark.cs b/DD.Persistence.Benchmark/Tests/WitsDataBenchmark.cs index 7e5d936..f69685a 100644 --- a/DD.Persistence.Benchmark/Tests/WitsDataBenchmark.cs +++ b/DD.Persistence.Benchmark/Tests/WitsDataBenchmark.cs @@ -22,25 +22,25 @@ public static class WitsDataBenchmark var client = persistenceClientFactory.GetWitsDataClient(); var source = new CancellationTokenSource(TimeSpan.FromSeconds(6000)); - var data = GenerateData(count); + //var data = GenerateData(count); var sw = new Stopwatch(); - var saved = 0; - foreach (var item in data) - { - var time = sw.Elapsed; + //var saved = 0; + //foreach (var item in data) + //{ + // var time = sw.Elapsed; - sw.Start(); - var response = await client.AddRange(item, source.Token); - sw.Stop(); - saved = saved + response; - Console.WriteLine($"Сохранено: {saved.ToString()}"); - } + // sw.Start(); + // var response = await client.AddRange(item, source.Token); + // sw.Stop(); + // saved = saved + response; + // Console.WriteLine($"Сохранено: {saved.ToString()}"); + //} - Console.WriteLine($"Затрачено времени на сохранение: {sw.Elapsed}"); + //Console.WriteLine($"Затрачено времени на сохранение: {sw.Elapsed}"); var discriminator = Guid.Parse(discriminatorId); - var date = DateTime.Now.AddDays(-1); + var date = DateTime.Now.AddDays(-31); Console.WriteLine($"\nВычитка..."); @@ -71,7 +71,7 @@ public static class WitsDataBenchmark { var random = new Random(); - var timestamped = DateTimeOffset.UtcNow.AddSeconds(random.Next(1, 60 * 60 * 24) * -1); + var timestamped = DateTimeOffset.UtcNow.AddSeconds(random.Next(1, 60 * 60 * 24 * 30) * -1); dtos.Add(new WitsDataDto() { diff --git a/DD.Persistence.Database.Postgres/Migrations/20241225094516_Init.Designer.cs b/DD.Persistence.Database.Postgres/Migrations/20241225122815_Init.Designer.cs similarity index 96% rename from DD.Persistence.Database.Postgres/Migrations/20241225094516_Init.Designer.cs rename to DD.Persistence.Database.Postgres/Migrations/20241225122815_Init.Designer.cs index 49436f3..82ebc55 100644 --- a/DD.Persistence.Database.Postgres/Migrations/20241225094516_Init.Designer.cs +++ b/DD.Persistence.Database.Postgres/Migrations/20241225122815_Init.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace DD.Persistence.Database.Postgres.Migrations { [DbContext(typeof(PersistencePostgresContext))] - [Migration("20241225094516_Init")] + [Migration("20241225122815_Init")] partial class Init { /// @@ -43,7 +43,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("SystemId"); - b.ToTable("DataSourceSystem"); + b.ToTable("data_source_system"); }); modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b => @@ -67,7 +67,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("DiscriminatorId", "ParameterId", "Timestamp"); - b.ToTable("ParameterData"); + b.ToTable("parameter_data"); }); modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => @@ -102,7 +102,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasIndex("SystemId"); - b.ToTable("TechMessage"); + b.ToTable("tech_message"); }); modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b => @@ -122,7 +122,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("IdDiscriminator", "Timestamp"); - b.ToTable("TimestampedSets", t => + b.ToTable("timestamped_set", t => { t.HasComment("Общая таблица данных временных рядов"); }); @@ -178,7 +178,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("Id"); - b.ToTable("ChangeLog"); + b.ToTable("change_log"); }); modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b => @@ -261,7 +261,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("Date"); - b.ToTable("DataSaub"); + b.ToTable("data_saub"); }); modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b => @@ -285,7 +285,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("Key", "Created"); - b.ToTable("Setpoint"); + b.ToTable("setpoint"); }); modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => diff --git a/DD.Persistence.Database.Postgres/Migrations/20241225094516_Init.cs b/DD.Persistence.Database.Postgres/Migrations/20241225122815_Init.cs similarity index 87% rename from DD.Persistence.Database.Postgres/Migrations/20241225094516_Init.cs rename to DD.Persistence.Database.Postgres/Migrations/20241225122815_Init.cs index 0f84480..11fb14d 100644 --- a/DD.Persistence.Database.Postgres/Migrations/20241225094516_Init.cs +++ b/DD.Persistence.Database.Postgres/Migrations/20241225122815_Init.cs @@ -12,7 +12,7 @@ namespace DD.Persistence.Database.Postgres.Migrations protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( - name: "ChangeLog", + name: "change_log", columns: table => new { Id = table.Column(type: "uuid", nullable: false, comment: "Ключ записи"), @@ -29,11 +29,11 @@ namespace DD.Persistence.Database.Postgres.Migrations }, constraints: table => { - table.PrimaryKey("PK_ChangeLog", x => x.Id); + table.PrimaryKey("PK_change_log", x => x.Id); }); migrationBuilder.CreateTable( - name: "DataSaub", + name: "data_saub", columns: table => new { date = table.Column(type: "timestamp with time zone", nullable: false), @@ -58,11 +58,11 @@ namespace DD.Persistence.Database.Postgres.Migrations }, constraints: table => { - table.PrimaryKey("PK_DataSaub", x => x.date); + table.PrimaryKey("PK_data_saub", x => x.date); }); migrationBuilder.CreateTable( - name: "DataSourceSystem", + name: "data_source_system", columns: table => new { SystemId = table.Column(type: "uuid", nullable: false, comment: "Id системы - источника данных"), @@ -71,11 +71,11 @@ namespace DD.Persistence.Database.Postgres.Migrations }, constraints: table => { - table.PrimaryKey("PK_DataSourceSystem", x => x.SystemId); + table.PrimaryKey("PK_data_source_system", x => x.SystemId); }); migrationBuilder.CreateTable( - name: "ParameterData", + name: "parameter_data", columns: table => new { DiscriminatorId = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор системы"), @@ -85,11 +85,11 @@ namespace DD.Persistence.Database.Postgres.Migrations }, 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( - name: "Setpoint", + name: "setpoint", columns: table => new { Key = table.Column(type: "uuid", nullable: false, comment: "Ключ"), @@ -99,11 +99,11 @@ namespace DD.Persistence.Database.Postgres.Migrations }, constraints: table => { - table.PrimaryKey("PK_Setpoint", x => new { x.Key, x.Created }); + table.PrimaryKey("PK_setpoint", x => new { x.Key, x.Created }); }); migrationBuilder.CreateTable( - name: "TimestampedSets", + name: "timestamped_set", columns: table => new { IdDiscriminator = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор ссылка на тип сохраняемых данных"), @@ -112,12 +112,12 @@ namespace DD.Persistence.Database.Postgres.Migrations }, constraints: table => { - table.PrimaryKey("PK_TimestampedSets", x => new { x.IdDiscriminator, x.Timestamp }); + table.PrimaryKey("PK_timestamped_set", x => new { x.IdDiscriminator, x.Timestamp }); }, comment: "Общая таблица данных временных рядов"); migrationBuilder.CreateTable( - name: "TechMessage", + name: "tech_message", columns: table => new { EventId = table.Column(type: "uuid", nullable: false, comment: "Id события"), @@ -129,18 +129,18 @@ namespace DD.Persistence.Database.Postgres.Migrations }, constraints: table => { - table.PrimaryKey("PK_TechMessage", x => x.EventId); + table.PrimaryKey("PK_tech_message", x => x.EventId); table.ForeignKey( - name: "FK_TechMessage_DataSourceSystem_SystemId", + name: "FK_tech_message_data_source_system_SystemId", column: x => x.SystemId, - principalTable: "DataSourceSystem", + principalTable: "data_source_system", principalColumn: "SystemId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( - name: "IX_TechMessage_SystemId", - table: "TechMessage", + name: "IX_tech_message_SystemId", + table: "tech_message", column: "SystemId"); } @@ -148,25 +148,25 @@ namespace DD.Persistence.Database.Postgres.Migrations protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( - name: "ChangeLog"); + name: "change_log"); migrationBuilder.DropTable( - name: "DataSaub"); + name: "data_saub"); migrationBuilder.DropTable( - name: "ParameterData"); + name: "parameter_data"); migrationBuilder.DropTable( - name: "Setpoint"); + name: "setpoint"); migrationBuilder.DropTable( - name: "TechMessage"); + name: "tech_message"); migrationBuilder.DropTable( - name: "TimestampedSets"); + name: "timestamped_set"); migrationBuilder.DropTable( - name: "DataSourceSystem"); + name: "data_source_system"); } } } diff --git a/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs b/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs index d3f619f..c50002e 100644 --- a/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs +++ b/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs @@ -40,7 +40,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("SystemId"); - b.ToTable("DataSourceSystem"); + b.ToTable("data_source_system"); }); modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b => @@ -64,7 +64,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("DiscriminatorId", "ParameterId", "Timestamp"); - b.ToTable("ParameterData"); + b.ToTable("parameter_data"); }); modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => @@ -99,7 +99,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasIndex("SystemId"); - b.ToTable("TechMessage"); + b.ToTable("tech_message"); }); modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b => @@ -119,7 +119,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("IdDiscriminator", "Timestamp"); - b.ToTable("TimestampedSets", t => + b.ToTable("timestamped_set", t => { t.HasComment("Общая таблица данных временных рядов"); }); @@ -175,7 +175,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("Id"); - b.ToTable("ChangeLog"); + b.ToTable("change_log"); }); modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b => @@ -258,7 +258,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("Date"); - b.ToTable("DataSaub"); + b.ToTable("data_saub"); }); modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b => @@ -282,7 +282,7 @@ namespace DD.Persistence.Database.Postgres.Migrations b.HasKey("Key", "Created"); - b.ToTable("Setpoint"); + b.ToTable("setpoint"); }); modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => diff --git a/DD.Persistence.Database/Entity/ChangeLog.cs b/DD.Persistence.Database/Entity/ChangeLog.cs index 439e886..a5254ae 100644 --- a/DD.Persistence.Database/Entity/ChangeLog.cs +++ b/DD.Persistence.Database/Entity/ChangeLog.cs @@ -9,6 +9,7 @@ namespace DD.Persistence.Database.Model; /// /// Часть записи, описывающая изменение /// +[Table("change_log")] public class ChangeLog : IChangeLog, IWithSectionPart { [Key, Comment("Ключ записи")] diff --git a/DD.Persistence.Database/Entity/DataSaub.cs b/DD.Persistence.Database/Entity/DataSaub.cs index d4515b2..0442fc4 100644 --- a/DD.Persistence.Database/Entity/DataSaub.cs +++ b/DD.Persistence.Database/Entity/DataSaub.cs @@ -2,6 +2,8 @@ using System.ComponentModel.DataAnnotations.Schema; namespace DD.Persistence.Database.Model; + +[Table("data_saub")] public class DataSaub : ITimestampedData { [Key, Column("date")] diff --git a/DD.Persistence.Database/Entity/DataSourceSystem.cs b/DD.Persistence.Database/Entity/DataSourceSystem.cs index d200731..b11e38e 100644 --- a/DD.Persistence.Database/Entity/DataSourceSystem.cs +++ b/DD.Persistence.Database/Entity/DataSourceSystem.cs @@ -3,6 +3,8 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace DD.Persistence.Database.Entity; + +[Table("data_source_system")] public class DataSourceSystem { [Key, Comment("Id системы - источника данных")] diff --git a/DD.Persistence.Database/Entity/ParameterData.cs b/DD.Persistence.Database/Entity/ParameterData.cs index b7f3c62..2b7bd7a 100644 --- a/DD.Persistence.Database/Entity/ParameterData.cs +++ b/DD.Persistence.Database/Entity/ParameterData.cs @@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema; namespace DD.Persistence.Database.Entity; -[Table("ParameterData")] +[Table("parameter_data")] [PrimaryKey(nameof(DiscriminatorId), nameof(ParameterId), nameof(Timestamp))] public class ParameterData { diff --git a/DD.Persistence.Database/Entity/Setpoint.cs b/DD.Persistence.Database/Entity/Setpoint.cs index 94eca3f..474fb28 100644 --- a/DD.Persistence.Database/Entity/Setpoint.cs +++ b/DD.Persistence.Database/Entity/Setpoint.cs @@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema; namespace DD.Persistence.Database.Model { + [Table("setpoint")] [PrimaryKey(nameof(Key), nameof(Created))] public class Setpoint { diff --git a/DD.Persistence.Database/Entity/TechMessage.cs b/DD.Persistence.Database/Entity/TechMessage.cs index e233941..4c7733b 100644 --- a/DD.Persistence.Database/Entity/TechMessage.cs +++ b/DD.Persistence.Database/Entity/TechMessage.cs @@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema; namespace DD.Persistence.Database.Entity { + [Table("tech_message")] public class TechMessage { [Key, Comment("Id события")] diff --git a/DD.Persistence.Database/Entity/TimestampedSet.cs b/DD.Persistence.Database/Entity/TimestampedSet.cs index f0d1815..10ffd2c 100644 --- a/DD.Persistence.Database/Entity/TimestampedSet.cs +++ b/DD.Persistence.Database/Entity/TimestampedSet.cs @@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema; namespace DD.Persistence.Database.Entity; +[Table("timestamped_set")] [Comment("Общая таблица данных временных рядов")] [PrimaryKey(nameof(IdDiscriminator), nameof(Timestamp))] public record TimestampedSet(