Ченджлог (начало)
This commit is contained in:
parent
f6648b812d
commit
381557459b
152
Persistence.Database.Postgres/Migrations/20241122124437_AddChangeLog.Designer.cs
generated
Normal file
152
Persistence.Database.Postgres/Migrations/20241122124437_AddChangeLog.Designer.cs
generated
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using Persistence.Database.Model;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Persistence.Database.Postgres.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(PersistenceDbContext))]
|
||||||
|
[Migration("20241122124437_AddChangeLog")]
|
||||||
|
partial class AddChangeLog
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
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("Persistence.Database.Model.ChangeLog", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("Id");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Creation")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("Creation");
|
||||||
|
|
||||||
|
b.Property<int>("IdAuthor")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("IdAuthor");
|
||||||
|
|
||||||
|
b.Property<int?>("IdEditor")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("IdEditor");
|
||||||
|
|
||||||
|
b.Property<int?>("IdNext")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("IdNext");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("Obsolete")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("Obsolete");
|
||||||
|
|
||||||
|
b.Property<object>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("Value");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("ChangeLog");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Persistence.Database.Model.DataSaub", b =>
|
||||||
|
{
|
||||||
|
b.Property<DateTimeOffset>("Date")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("date");
|
||||||
|
|
||||||
|
b.Property<double?>("AxialLoad")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("axialLoad");
|
||||||
|
|
||||||
|
b.Property<double?>("BitDepth")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("bitDepth");
|
||||||
|
|
||||||
|
b.Property<double?>("BlockPosition")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("blockPosition");
|
||||||
|
|
||||||
|
b.Property<double?>("BlockSpeed")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("blockSpeed");
|
||||||
|
|
||||||
|
b.Property<double?>("Flow")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("flow");
|
||||||
|
|
||||||
|
b.Property<double?>("HookWeight")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("hookWeight");
|
||||||
|
|
||||||
|
b.Property<int>("IdFeedRegulator")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("idFeedRegulator");
|
||||||
|
|
||||||
|
b.Property<int?>("Mode")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("mode");
|
||||||
|
|
||||||
|
b.Property<double?>("Mse")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("mse");
|
||||||
|
|
||||||
|
b.Property<short>("MseState")
|
||||||
|
.HasColumnType("smallint")
|
||||||
|
.HasColumnName("mseState");
|
||||||
|
|
||||||
|
b.Property<double?>("Pressure")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("pressure");
|
||||||
|
|
||||||
|
b.Property<double?>("Pump0Flow")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("pump0Flow");
|
||||||
|
|
||||||
|
b.Property<double?>("Pump1Flow")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("pump1Flow");
|
||||||
|
|
||||||
|
b.Property<double?>("Pump2Flow")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("pump2Flow");
|
||||||
|
|
||||||
|
b.Property<double?>("RotorSpeed")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("rotorSpeed");
|
||||||
|
|
||||||
|
b.Property<double?>("RotorTorque")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("rotorTorque");
|
||||||
|
|
||||||
|
b.Property<string>("User")
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("user");
|
||||||
|
|
||||||
|
b.Property<double?>("WellDepth")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("wellDepth");
|
||||||
|
|
||||||
|
b.HasKey("Date");
|
||||||
|
|
||||||
|
b.ToTable("DataSaub");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Persistence.Database.Postgres.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddChangeLog : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ChangeLog",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
IdAuthor = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
IdEditor = table.Column<int>(type: "integer", nullable: true),
|
||||||
|
Creation = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
|
Obsolete = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||||
|
IdNext = table.Column<int>(type: "integer", nullable: true),
|
||||||
|
Value = table.Column<object>(type: "jsonb", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ChangeLog", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ChangeLog");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,43 @@ namespace Persistence.Database.Postgres.Migrations
|
|||||||
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack");
|
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack");
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Persistence.Database.Model.ChangeLog", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("Id");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Creation")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("Creation");
|
||||||
|
|
||||||
|
b.Property<int>("IdAuthor")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("IdAuthor");
|
||||||
|
|
||||||
|
b.Property<int?>("IdEditor")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("IdEditor");
|
||||||
|
|
||||||
|
b.Property<int?>("IdNext")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("IdNext");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("Obsolete")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("Obsolete");
|
||||||
|
|
||||||
|
b.Property<object>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("Value");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("ChangeLog");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Persistence.Database.Model.DataSaub", b =>
|
modelBuilder.Entity("Persistence.Database.Model.DataSaub", b =>
|
||||||
{
|
{
|
||||||
b.Property<DateTimeOffset>("Date")
|
b.Property<DateTimeOffset>("Date")
|
||||||
|
@ -5,6 +5,7 @@ namespace Persistence.Database.Model;
|
|||||||
public partial class PersistenceDbContext : DbContext, IPersistenceDbContext
|
public partial class PersistenceDbContext : DbContext, IPersistenceDbContext
|
||||||
{
|
{
|
||||||
public DbSet<DataSaub> DataSaub => Set<DataSaub>();
|
public DbSet<DataSaub> DataSaub => Set<DataSaub>();
|
||||||
|
public DbSet<ChangeLog> ChangeLog => Set<ChangeLog>();
|
||||||
|
|
||||||
public PersistenceDbContext()
|
public PersistenceDbContext()
|
||||||
: base()
|
: base()
|
||||||
|
53
Persistence.Database/Entity/ChangeLogAbstractData.cs
Normal file
53
Persistence.Database/Entity/ChangeLogAbstractData.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Persistence.Database.Model;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Часть записи описывающая изменение
|
||||||
|
/// </summary>
|
||||||
|
public class ChangeLog : IChangeLogAbstractData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Ид записи
|
||||||
|
/// </summary>
|
||||||
|
[Key, Column("Id")]
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Автор изменения
|
||||||
|
/// </summary>
|
||||||
|
[Column("IdAuthor")]
|
||||||
|
public Guid IdAuthor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Редактор
|
||||||
|
/// </summary>
|
||||||
|
[Column("IdEditor")]
|
||||||
|
public Guid? IdEditor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата создания записи
|
||||||
|
/// </summary>
|
||||||
|
[Column("Creation")]
|
||||||
|
public DateTimeOffset Creation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата устаревания (например при удалении)
|
||||||
|
/// </summary>
|
||||||
|
[Column("Obsolete")]
|
||||||
|
public DateTimeOffset? Obsolete { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Id заменяющей записи
|
||||||
|
/// </summary>
|
||||||
|
[Column("IdNext")]
|
||||||
|
public Guid? IdNext { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Значение
|
||||||
|
/// </summary>
|
||||||
|
[Column("Value", TypeName = "jsonb")]
|
||||||
|
public required object Value { get; set; }
|
||||||
|
}
|
43
Persistence.Database/Entity/IChangeLogAbstractData.cs
Normal file
43
Persistence.Database/Entity/IChangeLogAbstractData.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
namespace Persistence.Database.Model;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Часть записи описывающая изменение
|
||||||
|
/// </summary>
|
||||||
|
public interface IChangeLogAbstractData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Ид записи
|
||||||
|
/// </summary>
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Автор изменения
|
||||||
|
/// </summary>
|
||||||
|
public int IdAuthor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Редактор
|
||||||
|
/// </summary>
|
||||||
|
public int? IdEditor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата создания записи
|
||||||
|
/// </summary>
|
||||||
|
public DateTimeOffset Creation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата устаревания (например при удалении)
|
||||||
|
/// </summary>
|
||||||
|
public DateTimeOffset? Obsolete { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Id заменяющей записи
|
||||||
|
/// </summary>
|
||||||
|
public int? IdNext { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Значение
|
||||||
|
/// </summary>
|
||||||
|
public object Value { get; set; }
|
||||||
|
}
|
@ -5,4 +5,5 @@ namespace Persistence.Database;
|
|||||||
public interface IPersistenceDbContext : IDisposable
|
public interface IPersistenceDbContext : IDisposable
|
||||||
{
|
{
|
||||||
DbSet<DataSaub> DataSaub { get; }
|
DbSet<DataSaub> DataSaub { get; }
|
||||||
|
DbSet<ChangeLog> ChangeLog { get; }
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
|
||||||
namespace Persistence.Models;
|
namespace Persistence.Models;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Часть записи описывающая изменение
|
/// Часть записи описывающая изменение
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ChangeLogDto<T> where T: class
|
public class ChangeLogDto<T> : IChangeLogAbstractDto
|
||||||
|
where T: class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Запись
|
/// Запись
|
||||||
@ -11,32 +13,37 @@ public class ChangeLogDto<T> where T: class
|
|||||||
public required T Item { get; set; }
|
public required T Item { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Автор
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UserDto? Author { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Автор
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UserDto? Editor { get; set; }
|
public int IdAuthor { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата создания записи
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int? IdEditor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTimeOffset Creation { get; set; }
|
public DateTimeOffset Creation { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата устаревания (например, при удалении)
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTimeOffset? Obsolete { get; set; }
|
public DateTimeOffset? Obsolete { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Id состояния
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int IdState { get; set; }
|
public int? IdNext { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Id заменяемой записи
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? IdPrevious { get; set; }
|
public required object Value { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -3,28 +3,8 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Часть записи описывающая изменение
|
/// Часть записи описывающая изменение
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IChangeLogAbstract
|
public interface IChangeLogAbstractDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Актуальная
|
|
||||||
/// </summary>
|
|
||||||
public const int IdStateActual = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Замененная
|
|
||||||
/// </summary>
|
|
||||||
public const int IdStateReplaced = 1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаленная
|
|
||||||
/// </summary>
|
|
||||||
public const int IdStateDeleted = 2;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Очищено при импорте
|
|
||||||
/// </summary>
|
|
||||||
public const int IdCleared = 3;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ид записи
|
/// Ид записи
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -51,12 +31,12 @@ public interface IChangeLogAbstract
|
|||||||
public DateTimeOffset? Obsolete { get; set; }
|
public DateTimeOffset? Obsolete { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// "ИД состояния записи: \n0 - актуальная\n1 - замененная\n2 - удаленная
|
/// Id заменяющей записи
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int IdState { get; set; }
|
public int? IdNext { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Id заменяемой записи
|
/// Значение
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? IdPrevious { get; set; }
|
public object Value { get; set; }
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user