From 6249b6cd969e7d211eab6536f6b7fec378cded63 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Wed, 18 Dec 2024 16:00:51 +0500 Subject: [PATCH] + --- .../20241118052225_SetpointMigration.cs | 35 --- .../20241126071115_Add_ChangeLog.Designer.cs | 169 ------------ .../20241126071115_Add_ChangeLog.cs | 42 --- .../20241126100631_Init.Designer.cs | 162 ----------- .../Migrations/20241126100631_Init.cs | 87 ------ ...3120141_ParameterDataMigration.Designer.cs | 257 ------------------ .../20241203120141_ParameterDataMigration.cs | 35 --- .../20241212041758_TechMessageMigration.cs | 64 ----- ...ner.cs => 20241218105317_Init.Designer.cs} | 22 +- .../Migrations/20241218105317_Init.cs | 175 ++++++++++++ ...PersistencePostgresContextModelSnapshot.cs | 4 +- 11 files changed, 188 insertions(+), 864 deletions(-) delete mode 100644 DD.Persistence.Database.Postgres/Migrations/20241118052225_SetpointMigration.cs delete mode 100644 DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.Designer.cs delete mode 100644 DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.cs delete mode 100644 DD.Persistence.Database.Postgres/Migrations/20241126100631_Init.Designer.cs delete mode 100644 DD.Persistence.Database.Postgres/Migrations/20241126100631_Init.cs delete mode 100644 DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.Designer.cs delete mode 100644 DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs delete mode 100644 DD.Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.cs rename DD.Persistence.Database.Postgres/Migrations/{20241212041758_TechMessageMigration.Designer.cs => 20241218105317_Init.Designer.cs} (95%) create mode 100644 DD.Persistence.Database.Postgres/Migrations/20241218105317_Init.cs diff --git a/DD.Persistence.Database.Postgres/Migrations/20241118052225_SetpointMigration.cs b/DD.Persistence.Database.Postgres/Migrations/20241118052225_SetpointMigration.cs deleted file mode 100644 index e9f5b95..0000000 --- a/DD.Persistence.Database.Postgres/Migrations/20241118052225_SetpointMigration.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DD.Persistence.Database.Postgres.Migrations -{ - /// - public partial class SetpointMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Setpoint", - columns: table => new - { - Key = table.Column(type: "uuid", nullable: false, comment: "Ключ"), - Created = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата изменения уставки"), - Value = table.Column(type: "jsonb", nullable: false, comment: "Значение уставки"), - IdUser = table.Column(type: "uuid", nullable: false, comment: "Id автора последнего изменения") - }, - constraints: table => - { - table.PrimaryKey("PK_Setpoint", x => new { x.Key, x.Created }); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Setpoint"); - } - } -} diff --git a/DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.Designer.cs b/DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.Designer.cs deleted file mode 100644 index 7fa7567..0000000 --- a/DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.Designer.cs +++ /dev/null @@ -1,169 +0,0 @@ -// -using System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using DD.Persistence.Database.Model; - -#nullable disable - -namespace DD.Persistence.Database.Postgres.Migrations -{ - [DbContext(typeof(PersistenceDbContext))] - [Migration("20241126071115_Add_ChangeLog")] - partial class Add_ChangeLog - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .UseCollation("Russian_Russia.1251") - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("DD.Persistence.Database.Model.ChangeLog", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("Id"); - - b.Property("Creation") - .HasColumnType("timestamp with time zone") - .HasColumnName("Creation"); - - b.Property("DepthEnd") - .HasColumnType("double precision") - .HasColumnName("DepthEnd"); - - b.Property("DepthStart") - .HasColumnType("double precision") - .HasColumnName("DepthStart"); - - b.Property("IdAuthor") - .HasColumnType("uuid") - .HasColumnName("IdAuthor"); - - b.Property("IdDiscriminator") - .HasColumnType("uuid") - .HasColumnName("IdDiscriminator"); - - b.Property("IdEditor") - .HasColumnType("uuid") - .HasColumnName("IdEditor"); - - b.Property("IdNext") - .HasColumnType("uuid") - .HasColumnName("IdNext"); - - b.Property("IdSection") - .HasColumnType("uuid") - .HasColumnName("IdSection"); - - b.Property("Obsolete") - .HasColumnType("timestamp with time zone") - .HasColumnName("Obsolete"); - - b.Property>("Value") - .IsRequired() - .HasColumnType("jsonb") - .HasColumnName("Value"); - - b.HasKey("Id"); - - b.ToTable("ChangeLog"); - }); - - modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b => - { - b.Property("Date") - .HasColumnType("timestamp with time zone") - .HasColumnName("date"); - - b.Property("AxialLoad") - .HasColumnType("double precision") - .HasColumnName("axialLoad"); - - b.Property("BitDepth") - .HasColumnType("double precision") - .HasColumnName("bitDepth"); - - b.Property("BlockPosition") - .HasColumnType("double precision") - .HasColumnName("blockPosition"); - - b.Property("BlockSpeed") - .HasColumnType("double precision") - .HasColumnName("blockSpeed"); - - b.Property("Flow") - .HasColumnType("double precision") - .HasColumnName("flow"); - - b.Property("HookWeight") - .HasColumnType("double precision") - .HasColumnName("hookWeight"); - - b.Property("IdFeedRegulator") - .HasColumnType("integer") - .HasColumnName("idFeedRegulator"); - - b.Property("Mode") - .HasColumnType("integer") - .HasColumnName("mode"); - - b.Property("Mse") - .HasColumnType("double precision") - .HasColumnName("mse"); - - b.Property("MseState") - .HasColumnType("smallint") - .HasColumnName("mseState"); - - b.Property("Pressure") - .HasColumnType("double precision") - .HasColumnName("pressure"); - - b.Property("Pump0Flow") - .HasColumnType("double precision") - .HasColumnName("pump0Flow"); - - b.Property("Pump1Flow") - .HasColumnType("double precision") - .HasColumnName("pump1Flow"); - - b.Property("Pump2Flow") - .HasColumnType("double precision") - .HasColumnName("pump2Flow"); - - b.Property("RotorSpeed") - .HasColumnType("double precision") - .HasColumnName("rotorSpeed"); - - b.Property("RotorTorque") - .HasColumnType("double precision") - .HasColumnName("rotorTorque"); - - b.Property("User") - .HasColumnType("text") - .HasColumnName("user"); - - b.Property("WellDepth") - .HasColumnType("double precision") - .HasColumnName("wellDepth"); - - b.HasKey("Date"); - - b.ToTable("DataSaub"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.cs b/DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.cs deleted file mode 100644 index e001cfe..0000000 --- a/DD.Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DD.Persistence.Database.Postgres.Migrations -{ - /// - public partial class Add_ChangeLog : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ChangeLog", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - IdDiscriminator = table.Column(type: "uuid", nullable: false), - IdAuthor = table.Column(type: "uuid", nullable: false), - IdEditor = table.Column(type: "uuid", nullable: true), - Creation = table.Column(type: "timestamp with time zone", nullable: false), - Obsolete = table.Column(type: "timestamp with time zone", nullable: true), - IdNext = table.Column(type: "uuid", nullable: true), - DepthStart = table.Column(type: "double precision", nullable: false), - DepthEnd = table.Column(type: "double precision", nullable: false), - IdSection = table.Column(type: "uuid", nullable: false), - Value = table.Column>(type: "jsonb", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ChangeLog", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ChangeLog"); - } - } -} diff --git a/DD.Persistence.Database.Postgres/Migrations/20241126100631_Init.Designer.cs b/DD.Persistence.Database.Postgres/Migrations/20241126100631_Init.Designer.cs deleted file mode 100644 index a43cb6a..0000000 --- a/DD.Persistence.Database.Postgres/Migrations/20241126100631_Init.Designer.cs +++ /dev/null @@ -1,162 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using DD.Persistence.Database.Model; - -#nullable disable - -namespace DD.Persistence.Database.Postgres.Migrations -{ - [DbContext(typeof(PersistencePostgresContext))] - [Migration("20241126100631_Init")] - partial class Init - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .UseCollation("Russian_Russia.1251") - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b => - { - b.Property("IdDiscriminator") - .HasColumnType("uuid") - .HasComment("Дискриминатор ссылка на тип сохраняемых данных"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone") - .HasComment("Отметка времени, строго в UTC"); - - b.Property("Set") - .IsRequired() - .HasColumnType("jsonb") - .HasComment("Набор сохраняемых данных"); - - b.HasKey("IdDiscriminator", "Timestamp"); - - b.ToTable("TimestampedSets", t => - { - t.HasComment("Общая таблица данных временных рядов"); - }); - }); - - modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b => - { - b.Property("Date") - .HasColumnType("timestamp with time zone") - .HasColumnName("date"); - - b.Property("AxialLoad") - .HasColumnType("double precision") - .HasColumnName("axialLoad"); - - b.Property("BitDepth") - .HasColumnType("double precision") - .HasColumnName("bitDepth"); - - b.Property("BlockPosition") - .HasColumnType("double precision") - .HasColumnName("blockPosition"); - - b.Property("BlockSpeed") - .HasColumnType("double precision") - .HasColumnName("blockSpeed"); - - b.Property("Flow") - .HasColumnType("double precision") - .HasColumnName("flow"); - - b.Property("HookWeight") - .HasColumnType("double precision") - .HasColumnName("hookWeight"); - - b.Property("IdFeedRegulator") - .HasColumnType("integer") - .HasColumnName("idFeedRegulator"); - - b.Property("Mode") - .HasColumnType("integer") - .HasColumnName("mode"); - - b.Property("Mse") - .HasColumnType("double precision") - .HasColumnName("mse"); - - b.Property("MseState") - .HasColumnType("smallint") - .HasColumnName("mseState"); - - b.Property("Pressure") - .HasColumnType("double precision") - .HasColumnName("pressure"); - - b.Property("Pump0Flow") - .HasColumnType("double precision") - .HasColumnName("pump0Flow"); - - b.Property("Pump1Flow") - .HasColumnType("double precision") - .HasColumnName("pump1Flow"); - - b.Property("Pump2Flow") - .HasColumnType("double precision") - .HasColumnName("pump2Flow"); - - b.Property("RotorSpeed") - .HasColumnType("double precision") - .HasColumnName("rotorSpeed"); - - b.Property("RotorTorque") - .HasColumnType("double precision") - .HasColumnName("rotorTorque"); - - b.Property("User") - .HasColumnType("text") - .HasColumnName("user"); - - b.Property("WellDepth") - .HasColumnType("double precision") - .HasColumnName("wellDepth"); - - b.HasKey("Date"); - - b.ToTable("DataSaub"); - }); - - modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b => - { - b.Property("Key") - .HasColumnType("uuid") - .HasComment("Ключ"); - - b.Property("Created") - .HasColumnType("timestamp with time zone") - .HasComment("Дата создания уставки"); - - b.Property("IdUser") - .HasColumnType("integer") - .HasComment("Id автора последнего изменения"); - - b.Property("Value") - .IsRequired() - .HasColumnType("jsonb") - .HasComment("Значение уставки"); - - b.HasKey("Key", "Created"); - - b.ToTable("Setpoint"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DD.Persistence.Database.Postgres/Migrations/20241126100631_Init.cs b/DD.Persistence.Database.Postgres/Migrations/20241126100631_Init.cs deleted file mode 100644 index 9bbd704..0000000 --- a/DD.Persistence.Database.Postgres/Migrations/20241126100631_Init.cs +++ /dev/null @@ -1,87 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DD.Persistence.Database.Postgres.Migrations -{ - /// - public partial class Init : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterDatabase() - .Annotation("Npgsql:PostgresExtension:adminpack", ",,"); - - migrationBuilder.CreateTable( - name: "DataSaub", - columns: table => new - { - date = table.Column(type: "timestamp with time zone", nullable: false), - mode = table.Column(type: "integer", nullable: true), - user = table.Column(type: "text", nullable: true), - wellDepth = table.Column(type: "double precision", nullable: true), - bitDepth = table.Column(type: "double precision", nullable: true), - blockPosition = table.Column(type: "double precision", nullable: true), - blockSpeed = table.Column(type: "double precision", nullable: true), - pressure = table.Column(type: "double precision", nullable: true), - axialLoad = table.Column(type: "double precision", nullable: true), - hookWeight = table.Column(type: "double precision", nullable: true), - rotorTorque = table.Column(type: "double precision", nullable: true), - rotorSpeed = table.Column(type: "double precision", nullable: true), - flow = table.Column(type: "double precision", nullable: true), - mseState = table.Column(type: "smallint", nullable: false), - idFeedRegulator = table.Column(type: "integer", nullable: false), - mse = table.Column(type: "double precision", nullable: true), - pump0Flow = table.Column(type: "double precision", nullable: true), - pump1Flow = table.Column(type: "double precision", nullable: true), - pump2Flow = table.Column(type: "double precision", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_DataSaub", x => x.date); - }); - - migrationBuilder.CreateTable( - name: "Setpoint", - columns: table => new - { - Key = table.Column(type: "uuid", nullable: false, comment: "Ключ"), - Created = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата создания уставки"), - Value = table.Column(type: "jsonb", nullable: false, comment: "Значение уставки"), - IdUser = table.Column(type: "integer", nullable: false, comment: "Id автора последнего изменения") - }, - constraints: table => - { - table.PrimaryKey("PK_Setpoint", x => new { x.Key, x.Created }); - }); - - migrationBuilder.CreateTable( - name: "TimestampedSets", - columns: table => new - { - IdDiscriminator = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор ссылка на тип сохраняемых данных"), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Отметка времени, строго в UTC"), - Set = table.Column(type: "jsonb", nullable: false, comment: "Набор сохраняемых данных") - }, - constraints: table => - { - table.PrimaryKey("PK_TimestampedSets", x => new { x.IdDiscriminator, x.Timestamp }); - }, - comment: "Общая таблица данных временных рядов"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "DataSaub"); - - migrationBuilder.DropTable( - name: "Setpoint"); - - migrationBuilder.DropTable( - name: "TimestampedSets"); - } - } -} diff --git a/DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.Designer.cs b/DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.Designer.cs deleted file mode 100644 index 2afaaa3..0000000 --- a/DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.Designer.cs +++ /dev/null @@ -1,257 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using DD.Persistence.Database.Model; - -#nullable disable - -namespace DD.Persistence.Database.Postgres.Migrations -{ - [DbContext(typeof(PersistenceDbContext))] - [Migration("20241203120141_ParameterDataMigration")] - partial class ParameterDataMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .UseCollation("Russian_Russia.1251") - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("DD.Persistence.Database.Entity.DrillingSystem", b => - { - b.Property("SystemId") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasComment("Id системы автобурения"); - - b.Property("Description") - .HasColumnType("text") - .HasComment("Описание системы автобурения"); - - b.Property("Name") - .IsRequired() - .HasColumnType("varchar(256)") - .HasComment("Наименование системы автобурения"); - - b.HasKey("SystemId"); - - b.ToTable("DrillingSystem"); - }); - - modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b => - { - b.Property("DiscriminatorId") - .HasColumnType("integer") - .HasComment("Дискриминатор системы"); - - b.Property("ParameterId") - .HasColumnType("integer") - .HasComment("Id параметра"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone") - .HasComment("Временная отметка"); - - b.Property("Value") - .IsRequired() - .HasColumnType("varchar(256)") - .HasComment("Значение параметра в виде строки"); - - b.HasKey("DiscriminatorId", "ParameterId", "Timestamp"); - - b.ToTable("ParameterData"); - }); - - modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => - { - b.Property("EventId") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasComment("Id события"); - - b.Property("CategoryId") - .HasColumnType("integer") - .HasComment("Id Категории важности"); - - b.Property("Depth") - .HasColumnType("double precision") - .HasComment("Глубина забоя"); - - b.Property("MessageText") - .IsRequired() - .HasColumnType("varchar(512)") - .HasComment("Текст сообщения"); - - b.Property("SystemId") - .HasColumnType("uuid") - .HasComment("Id системы автобурения, к которой относится сообщение"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone") - .HasComment("Дата возникновения"); - - b.Property("UserId") - .HasColumnType("uuid") - .HasComment("Id пользователя за пультом бурильщика"); - - b.HasKey("EventId"); - - b.HasIndex("SystemId"); - - b.ToTable("TechMessage"); - }); - - modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b => - { - b.Property("IdDiscriminator") - .HasColumnType("uuid") - .HasComment("Дискриминатор ссылка на тип сохраняемых данных"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone") - .HasComment("Отметка времени, строго в UTC"); - - b.Property("Set") - .IsRequired() - .HasColumnType("jsonb") - .HasComment("Набор сохраняемых данных"); - - b.HasKey("IdDiscriminator", "Timestamp"); - - b.ToTable("TimestampedSets", t => - { - t.HasComment("Общая таблица данных временных рядов"); - }); - }); - - modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b => - { - b.Property("Date") - .HasColumnType("timestamp with time zone") - .HasColumnName("date"); - - b.Property("AxialLoad") - .HasColumnType("double precision") - .HasColumnName("axialLoad"); - - b.Property("BitDepth") - .HasColumnType("double precision") - .HasColumnName("bitDepth"); - - b.Property("BlockPosition") - .HasColumnType("double precision") - .HasColumnName("blockPosition"); - - b.Property("BlockSpeed") - .HasColumnType("double precision") - .HasColumnName("blockSpeed"); - - b.Property("Flow") - .HasColumnType("double precision") - .HasColumnName("flow"); - - b.Property("HookWeight") - .HasColumnType("double precision") - .HasColumnName("hookWeight"); - - b.Property("IdFeedRegulator") - .HasColumnType("integer") - .HasColumnName("idFeedRegulator"); - - b.Property("Mode") - .HasColumnType("integer") - .HasColumnName("mode"); - - b.Property("Mse") - .HasColumnType("double precision") - .HasColumnName("mse"); - - b.Property("MseState") - .HasColumnType("smallint") - .HasColumnName("mseState"); - - b.Property("Pressure") - .HasColumnType("double precision") - .HasColumnName("pressure"); - - b.Property("Pump0Flow") - .HasColumnType("double precision") - .HasColumnName("pump0Flow"); - - b.Property("Pump1Flow") - .HasColumnType("double precision") - .HasColumnName("pump1Flow"); - - b.Property("Pump2Flow") - .HasColumnType("double precision") - .HasColumnName("pump2Flow"); - - b.Property("RotorSpeed") - .HasColumnType("double precision") - .HasColumnName("rotorSpeed"); - - b.Property("RotorTorque") - .HasColumnType("double precision") - .HasColumnName("rotorTorque"); - - b.Property("User") - .HasColumnType("text") - .HasColumnName("user"); - - b.Property("WellDepth") - .HasColumnType("double precision") - .HasColumnName("wellDepth"); - - b.HasKey("Date"); - - b.ToTable("DataSaub"); - }); - - modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b => - { - b.Property("Key") - .HasColumnType("uuid") - .HasComment("Ключ"); - - b.Property("Created") - .HasColumnType("timestamp with time zone") - .HasComment("Дата создания уставки"); - - b.Property("IdUser") - .HasColumnType("uuid") - .HasComment("Id автора последнего изменения"); - - b.Property("Value") - .IsRequired() - .HasColumnType("jsonb") - .HasComment("Значение уставки"); - - b.HasKey("Key", "Created"); - - b.ToTable("Setpoint"); - }); - - modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => - { - b.HasOne("DD.Persistence.Database.Entity.DrillingSystem", "System") - .WithMany() - .HasForeignKey("SystemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("System"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs b/DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs deleted file mode 100644 index 830f5b9..0000000 --- a/DD.Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DD.Persistence.Database.Postgres.Migrations -{ - /// - public partial class ParameterDataMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ParameterData", - columns: table => new - { - DiscriminatorId = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор системы"), - ParameterId = table.Column(type: "integer", nullable: false, comment: "Id параметра"), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"), - Value = table.Column(type: "varchar(256)", nullable: false, comment: "Значение параметра в виде строки") - }, - constraints: table => - { - table.PrimaryKey("PK_ParameterData", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp }); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ParameterData"); - } - } -} diff --git a/DD.Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.cs b/DD.Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.cs deleted file mode 100644 index 04be23a..0000000 --- a/DD.Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DD.Persistence.Database.Postgres.Migrations.PersistencePostgres -{ - /// - public partial class TechMessageMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "DataSourceSystem", - columns: table => new - { - SystemId = table.Column(type: "uuid", nullable: false, comment: "Id системы - источника данных"), - Name = table.Column(type: "varchar(256)", nullable: false, comment: "Наименование системы - источника данных"), - Description = table.Column(type: "text", nullable: true, comment: "Описание системы - источника данных") - }, - constraints: table => - { - table.PrimaryKey("PK_DataSourceSystem", x => x.SystemId); - }); - - migrationBuilder.CreateTable( - name: "TechMessage", - columns: table => new - { - EventId = table.Column(type: "uuid", nullable: false, comment: "Id события"), - CategoryId = table.Column(type: "integer", nullable: false, comment: "Id Категории важности"), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата возникновения"), - Text = table.Column(type: "varchar(512)", nullable: false, comment: "Текст сообщения"), - SystemId = table.Column(type: "uuid", nullable: false, comment: "Id системы, к которой относится сообщение"), - EventState = table.Column(type: "integer", nullable: false, comment: "Статус события") - }, - constraints: table => - { - table.PrimaryKey("PK_TechMessage", x => x.EventId); - table.ForeignKey( - name: "FK_TechMessage_DataSourceSystem_SystemId", - column: x => x.SystemId, - principalTable: "DataSourceSystem", - principalColumn: "SystemId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_TechMessage_SystemId", - table: "TechMessage", - column: "SystemId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TechMessage"); - - migrationBuilder.DropTable( - name: "DataSourceSystem"); - } - } -} diff --git a/DD.Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.Designer.cs b/DD.Persistence.Database.Postgres/Migrations/20241218105317_Init.Designer.cs similarity index 95% rename from DD.Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.Designer.cs rename to DD.Persistence.Database.Postgres/Migrations/20241218105317_Init.Designer.cs index 1e28de3..173417c 100644 --- a/DD.Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.Designer.cs +++ b/DD.Persistence.Database.Postgres/Migrations/20241218105317_Init.Designer.cs @@ -1,51 +1,51 @@ // using System; +using DD.Persistence.Database.Model; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using DD.Persistence.Database.Model; #nullable disable -namespace DD.Persistence.Database.Postgres.Migrations.PersistencePostgres +namespace DD.Persistence.Database.Postgres.Migrations { [DbContext(typeof(PersistencePostgresContext))] - [Migration("20241212041758_TechMessageMigration")] - partial class TechMessageMigration + [Migration("20241218105317_Init")] + partial class Init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .UseCollation("Russian_Russia.1251") + .UseCollation("utf8mb4_general_ci") .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("DD.Persistence.Database.Entity.DrillingSystem", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.DataSourceSystem", b => { b.Property("SystemId") .ValueGeneratedOnAdd() .HasColumnType("uuid") - .HasComment("Id системы автобурения"); + .HasComment("Id системы - источника данных"); b.Property("Description") .HasColumnType("text") - .HasComment("Описание системы автобурения"); + .HasComment("Описание системы - источника данных"); b.Property("Name") .IsRequired() .HasColumnType("varchar(256)") - .HasComment("Наименование системы автобурения"); + .HasComment("Наименование системы - источника данных"); b.HasKey("SystemId"); - b.ToTable("DrillingSystem"); + b.ToTable("DataSourceSystem"); }); modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b => @@ -292,7 +292,7 @@ namespace DD.Persistence.Database.Postgres.Migrations.PersistencePostgres modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => { - b.HasOne("DD.Persistence.Database.Entity.DrillingSystem", "System") + b.HasOne("DD.Persistence.Database.Entity.DataSourceSystem", "System") .WithMany() .HasForeignKey("SystemId") .OnDelete(DeleteBehavior.Cascade) diff --git a/DD.Persistence.Database.Postgres/Migrations/20241218105317_Init.cs b/DD.Persistence.Database.Postgres/Migrations/20241218105317_Init.cs new file mode 100644 index 0000000..95f33d2 --- /dev/null +++ b/DD.Persistence.Database.Postgres/Migrations/20241218105317_Init.cs @@ -0,0 +1,175 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DD.Persistence.Database.Postgres.Migrations +{ + /// + public partial class Init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("Npgsql:PostgresExtension:adminpack", ",,"); + + migrationBuilder.CreateTable( + name: "ChangeLog", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false, comment: "Ключ записи"), + IdDiscriminator = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор таблицы"), + IdAuthor = table.Column(type: "uuid", nullable: false, comment: "Автор изменения"), + IdEditor = table.Column(type: "uuid", nullable: true, comment: "Редактор"), + Creation = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата создания записи"), + Obsolete = table.Column(type: "timestamp with time zone", nullable: true, comment: "Дата устаревания (например при удалении)"), + IdNext = table.Column(type: "uuid", nullable: true, comment: "Id заменяющей записи"), + DepthStart = table.Column(type: "double precision", nullable: false, comment: "Глубина забоя на дату начала интервала"), + DepthEnd = table.Column(type: "double precision", nullable: false, comment: "Глубина забоя на дату окончания интервала"), + IdSection = table.Column(type: "uuid", nullable: false, comment: "Ключ секции"), + Value = table.Column(type: "jsonb", nullable: false, comment: "Значение") + }, + constraints: table => + { + table.PrimaryKey("PK_ChangeLog", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "DataSaub", + columns: table => new + { + date = table.Column(type: "timestamp with time zone", nullable: false), + mode = table.Column(type: "integer", nullable: true), + user = table.Column(type: "text", nullable: true), + wellDepth = table.Column(type: "double precision", nullable: true), + bitDepth = table.Column(type: "double precision", nullable: true), + blockPosition = table.Column(type: "double precision", nullable: true), + blockSpeed = table.Column(type: "double precision", nullable: true), + pressure = table.Column(type: "double precision", nullable: true), + axialLoad = table.Column(type: "double precision", nullable: true), + hookWeight = table.Column(type: "double precision", nullable: true), + rotorTorque = table.Column(type: "double precision", nullable: true), + rotorSpeed = table.Column(type: "double precision", nullable: true), + flow = table.Column(type: "double precision", nullable: true), + mseState = table.Column(type: "smallint", nullable: false), + idFeedRegulator = table.Column(type: "integer", nullable: false), + mse = table.Column(type: "double precision", nullable: true), + pump0Flow = table.Column(type: "double precision", nullable: true), + pump1Flow = table.Column(type: "double precision", nullable: true), + pump2Flow = table.Column(type: "double precision", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_DataSaub", x => x.date); + }); + + migrationBuilder.CreateTable( + name: "DataSourceSystem", + columns: table => new + { + SystemId = table.Column(type: "uuid", nullable: false, comment: "Id системы - источника данных"), + Name = table.Column(type: "varchar(256)", nullable: false, comment: "Наименование системы - источника данных"), + Description = table.Column(type: "text", nullable: true, comment: "Описание системы - источника данных") + }, + constraints: table => + { + table.PrimaryKey("PK_DataSourceSystem", x => x.SystemId); + }); + + migrationBuilder.CreateTable( + name: "ParameterData", + columns: table => new + { + DiscriminatorId = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор системы"), + ParameterId = table.Column(type: "integer", nullable: false, comment: "Id параметра"), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"), + Value = table.Column(type: "varchar(256)", nullable: false, comment: "Значение параметра в виде строки") + }, + constraints: table => + { + table.PrimaryKey("PK_ParameterData", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp }); + }); + + migrationBuilder.CreateTable( + name: "Setpoint", + columns: table => new + { + Key = table.Column(type: "uuid", nullable: false, comment: "Ключ"), + Created = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата создания уставки"), + Value = table.Column(type: "jsonb", nullable: false, comment: "Значение уставки"), + IdUser = table.Column(type: "uuid", nullable: false, comment: "Id автора последнего изменения") + }, + constraints: table => + { + table.PrimaryKey("PK_Setpoint", x => new { x.Key, x.Created }); + }); + + migrationBuilder.CreateTable( + name: "TimestampedSets", + columns: table => new + { + IdDiscriminator = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор ссылка на тип сохраняемых данных"), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Отметка времени, строго в UTC"), + Set = table.Column(type: "jsonb", nullable: false, comment: "Набор сохраняемых данных") + }, + constraints: table => + { + table.PrimaryKey("PK_TimestampedSets", x => new { x.IdDiscriminator, x.Timestamp }); + }, + comment: "Общая таблица данных временных рядов"); + + migrationBuilder.CreateTable( + name: "TechMessage", + columns: table => new + { + EventId = table.Column(type: "uuid", nullable: false, comment: "Id события"), + CategoryId = table.Column(type: "integer", nullable: false, comment: "Id Категории важности"), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата возникновения"), + Text = table.Column(type: "varchar(512)", nullable: false, comment: "Текст сообщения"), + SystemId = table.Column(type: "uuid", nullable: false, comment: "Id системы, к которой относится сообщение"), + EventState = table.Column(type: "integer", nullable: false, comment: "Статус события") + }, + constraints: table => + { + table.PrimaryKey("PK_TechMessage", x => x.EventId); + table.ForeignKey( + name: "FK_TechMessage_DataSourceSystem_SystemId", + column: x => x.SystemId, + principalTable: "DataSourceSystem", + principalColumn: "SystemId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_TechMessage_SystemId", + table: "TechMessage", + column: "SystemId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ChangeLog"); + + migrationBuilder.DropTable( + name: "DataSaub"); + + migrationBuilder.DropTable( + name: "ParameterData"); + + migrationBuilder.DropTable( + name: "Setpoint"); + + migrationBuilder.DropTable( + name: "TechMessage"); + + migrationBuilder.DropTable( + name: "TimestampedSets"); + + migrationBuilder.DropTable( + name: "DataSourceSystem"); + } + } +} diff --git a/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs b/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs index 7123252..820fc31 100644 --- a/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs +++ b/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs @@ -1,10 +1,10 @@ // using System; +using DD.Persistence.Database.Model; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using DD.Persistence.Database.Model; #nullable disable @@ -17,7 +17,7 @@ namespace DD.Persistence.Database.Postgres.Migrations { #pragma warning disable 612, 618 modelBuilder - //.UseCollation("Russian_Russia.1251") + .UseCollation("utf8mb4_general_ci") .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 63);