feat: update db, move autogen db slop to subdir

This commit is contained in:
2026-03-18 19:33:56 +03:00
parent d2fa10003e
commit bbf233d14c
11 changed files with 64 additions and 64 deletions
@@ -28,8 +28,8 @@ public class AmineContentCalibrationContext : DbContext
{ {
entity.HasKey(x => x.Id); entity.HasKey(x => x.Id);
entity.HasMany(x => x.Images) entity.HasMany(x => x.Images)
.WithOne(x => x.Separator) .WithOne(x => x.UsedInSeparatorRecord)
.HasForeignKey(x => x.SeparatorRecordId) .HasForeignKey(x => x.UsedInSeparatorRecordId)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
entity.Property(x => x.Type) entity.Property(x => x.Type)
.IsRequired() .IsRequired()
@@ -43,11 +43,11 @@ public class AmineContentCalibrationContext : DbContext
{ {
entity.HasKey(x => x.Id); entity.HasKey(x => x.Id);
entity.HasMany(x => x.SampleImages) entity.HasMany(x => x.SampleImages)
.WithOne(x => x.CalibrationSample) .WithOne(x => x.UsedInCalibrationRecordSample)
.HasForeignKey(x => x.CalibrationSampleId) .HasForeignKey(x => x.UsedInCalibrationRecordSampleId)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
entity.HasMany(x => x.SeparatorImages) entity.HasMany(x => x.SeparatorImages)
.WithMany(x => x.UsedInCalibrations) .WithMany(x => x.UsedInCalibrationRecordsSeparator)
.UsingEntity<Dictionary<string, object>>( .UsingEntity<Dictionary<string, object>>(
"CalibrationSeparatorImage", "CalibrationSeparatorImage",
j => j j => j
@@ -26,7 +26,7 @@ public record CalibrationRecord
public required double? MixtureNormalRate { get; set; } public required double? MixtureNormalRate { get; set; }
[Comment("Фактический расход кондиционирующей смеси (кг/т | гр/кг)")] [Comment("Фактический расход кондиционирующей смеси (кг/т | гр/кг)")]
public required double? MixtureActualRate { get; set; } public required double? MixtureActualRate { get; set; }
[Comment("Измеренное колличество масла (кг/т | гр/кг)")] [Comment("Измеренное количество масла (кг/т | гр/кг)")]
public required double? MeasuredContent { get; set; } public required double? MeasuredContent { get; set; }
[Comment("Изображения пробы")] [Comment("Изображения пробы")]
public required List<ImageRecord> SampleImages { get; set; } public required List<ImageRecord> SampleImages { get; set; }
@@ -16,12 +16,12 @@ public record ImageRecord
public required string ImagePath { get; set; } public required string ImagePath { get; set; }
// 1:N // 1:N
public int? SeparatorRecordId { get; set; } public int? UsedInSeparatorRecordId { get; set; }
public SeparatorRecord? Separator { get; set; } public SeparatorRecord? UsedInSeparatorRecord { get; set; }
public int? CalibrationSampleId { get; set; } public int? UsedInCalibrationRecordSampleId { get; set; }
public CalibrationRecord? CalibrationSample { get; set; } public CalibrationRecord? UsedInCalibrationRecordSample { get; set; }
// M:N // M:N
public List<CalibrationRecord> UsedInCalibrations { get; set; } = new(); public List<CalibrationRecord> UsedInCalibrationRecordsSeparator { get; set; } = new();
} }
@@ -8,11 +8,11 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable #nullable disable
namespace GSS2.Core.Analysis.AmineContent.Database.Calibration namespace GSS2.Core.Analysis.AmineContent.Database.Calibration.Migrations
{ {
[DbContext(typeof(AmineContentCalibrationContext))] [DbContext(typeof(AmineContentCalibrationContext))]
[Migration("20260303084152_AmineContentCalibrationInitial")] [Migration("20260313083001_AmineContentCalibration0")]
partial class AmineContentCalibrationInitial partial class AmineContentCalibration0
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -44,7 +44,7 @@ namespace GSS2.Core.Analysis.AmineContent.Database.Calibration
b.Property<double?>("MeasuredContent") b.Property<double?>("MeasuredContent")
.HasColumnType("REAL") .HasColumnType("REAL")
.HasComment("Измеренное колличество масла (кг/т | гр/кг)"); .HasComment("Измеренное количество масла (кг/т | гр/кг)");
b.Property<double?>("MixtureActualRate") b.Property<double?>("MixtureActualRate")
.HasColumnType("REAL") .HasColumnType("REAL")
@@ -103,16 +103,16 @@ namespace GSS2.Core.Analysis.AmineContent.Database.Calibration
.HasColumnType("INTEGER") .HasColumnType("INTEGER")
.HasComment("Уникальный идентификатор"); .HasComment("Уникальный идентификатор");
b.Property<int?>("CalibrationSampleId")
.HasColumnType("INTEGER");
b.Property<string>("ImagePath") b.Property<string>("ImagePath")
.IsRequired() .IsRequired()
.HasMaxLength(1024) .HasMaxLength(1024)
.HasColumnType("TEXT") .HasColumnType("TEXT")
.HasComment("Путь к файлу изображения"); .HasComment("Путь к файлу изображения");
b.Property<int?>("SeparatorRecordId") b.Property<int?>("UsedInCalibrationRecordSampleId")
.HasColumnType("INTEGER");
b.Property<int?>("UsedInSeparatorRecordId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<double>("Uv254Intensity") b.Property<double>("Uv254Intensity")
@@ -129,9 +129,9 @@ namespace GSS2.Core.Analysis.AmineContent.Database.Calibration
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CalibrationSampleId"); b.HasIndex("UsedInCalibrationRecordSampleId");
b.HasIndex("SeparatorRecordId"); b.HasIndex("UsedInSeparatorRecordId");
b.ToTable("ImageRecords"); b.ToTable("ImageRecords");
}); });
@@ -177,19 +177,19 @@ namespace GSS2.Core.Analysis.AmineContent.Database.Calibration
modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.Calibration.ImageRecord", b => modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.Calibration.ImageRecord", b =>
{ {
b.HasOne("GSS2.Core.Analysis.AmineContent.Database.Calibration.CalibrationRecord", "CalibrationSample") b.HasOne("GSS2.Core.Analysis.AmineContent.Database.Calibration.CalibrationRecord", "UsedInCalibrationRecordSample")
.WithMany("SampleImages") .WithMany("SampleImages")
.HasForeignKey("CalibrationSampleId") .HasForeignKey("UsedInCalibrationRecordSampleId")
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
b.HasOne("GSS2.Core.Analysis.AmineContent.Database.Calibration.SeparatorRecord", "Separator") b.HasOne("GSS2.Core.Analysis.AmineContent.Database.Calibration.SeparatorRecord", "UsedInSeparatorRecord")
.WithMany("Images") .WithMany("Images")
.HasForeignKey("SeparatorRecordId") .HasForeignKey("UsedInSeparatorRecordId")
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
b.Navigation("CalibrationSample"); b.Navigation("UsedInCalibrationRecordSample");
b.Navigation("Separator"); b.Navigation("UsedInSeparatorRecord");
}); });
modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.Calibration.CalibrationRecord", b => modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.Calibration.CalibrationRecord", b =>
@@ -3,10 +3,10 @@ using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
namespace GSS2.Core.Analysis.AmineContent.Database.Calibration namespace GSS2.Core.Analysis.AmineContent.Database.Calibration.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class AmineContentCalibrationInitial : Migration public partial class AmineContentCalibration0 : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
@@ -27,7 +27,7 @@ namespace GSS2.Core.Analysis.AmineContent.Database.Calibration
MixtureAmineContent = table.Column<double>(type: "REAL", nullable: true, comment: "Содержание аминов в кондиционирующей смеси (%)"), MixtureAmineContent = table.Column<double>(type: "REAL", nullable: true, comment: "Содержание аминов в кондиционирующей смеси (%)"),
MixtureNormalRate = table.Column<double>(type: "REAL", nullable: true, comment: "Норма расхода кондиционирующей смеси (кг/т | гр/кг)"), MixtureNormalRate = table.Column<double>(type: "REAL", nullable: true, comment: "Норма расхода кондиционирующей смеси (кг/т | гр/кг)"),
MixtureActualRate = table.Column<double>(type: "REAL", nullable: true, comment: "Фактический расход кондиционирующей смеси (кг/т | гр/кг)"), MixtureActualRate = table.Column<double>(type: "REAL", nullable: true, comment: "Фактический расход кондиционирующей смеси (кг/т | гр/кг)"),
MeasuredContent = table.Column<double>(type: "REAL", nullable: true, comment: "Измеренное колличество масла (кг/т | гр/кг)") MeasuredContent = table.Column<double>(type: "REAL", nullable: true, comment: "Измеренное количество масла (кг/т | гр/кг)")
}, },
constraints: table => constraints: table =>
{ {
@@ -58,21 +58,21 @@ namespace GSS2.Core.Analysis.AmineContent.Database.Calibration
Uv365Intensity = table.Column<double>(type: "REAL", nullable: false, comment: "Интенсивность УФ излучения 365 нм (0..1)"), Uv365Intensity = table.Column<double>(type: "REAL", nullable: false, comment: "Интенсивность УФ излучения 365 нм (0..1)"),
Uv254Intensity = table.Column<double>(type: "REAL", nullable: false, comment: "Интенсивность УФ излучения 254 нм (0..1)"), Uv254Intensity = table.Column<double>(type: "REAL", nullable: false, comment: "Интенсивность УФ излучения 254 нм (0..1)"),
ImagePath = table.Column<string>(type: "TEXT", maxLength: 1024, nullable: false, comment: "Путь к файлу изображения"), ImagePath = table.Column<string>(type: "TEXT", maxLength: 1024, nullable: false, comment: "Путь к файлу изображения"),
SeparatorRecordId = table.Column<int>(type: "INTEGER", nullable: true), UsedInSeparatorRecordId = table.Column<int>(type: "INTEGER", nullable: true),
CalibrationSampleId = table.Column<int>(type: "INTEGER", nullable: true) UsedInCalibrationRecordSampleId = table.Column<int>(type: "INTEGER", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_ImageRecords", x => x.Id); table.PrimaryKey("PK_ImageRecords", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_ImageRecords_CalibrationRecords_CalibrationSampleId", name: "FK_ImageRecords_CalibrationRecords_UsedInCalibrationRecordSampleId",
column: x => x.CalibrationSampleId, column: x => x.UsedInCalibrationRecordSampleId,
principalTable: "CalibrationRecords", principalTable: "CalibrationRecords",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_ImageRecords_SeparatorRecords_SeparatorRecordId", name: "FK_ImageRecords_SeparatorRecords_UsedInSeparatorRecordId",
column: x => x.SeparatorRecordId, column: x => x.UsedInSeparatorRecordId,
principalTable: "SeparatorRecords", principalTable: "SeparatorRecords",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
@@ -108,14 +108,14 @@ namespace GSS2.Core.Analysis.AmineContent.Database.Calibration
column: "ImageRecordId"); column: "ImageRecordId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_ImageRecords_CalibrationSampleId", name: "IX_ImageRecords_UsedInCalibrationRecordSampleId",
table: "ImageRecords", table: "ImageRecords",
column: "CalibrationSampleId"); column: "UsedInCalibrationRecordSampleId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_ImageRecords_SeparatorRecordId", name: "IX_ImageRecords_UsedInSeparatorRecordId",
table: "ImageRecords", table: "ImageRecords",
column: "SeparatorRecordId"); column: "UsedInSeparatorRecordId");
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable #nullable disable
namespace GSS2.Core.Analysis.AmineContent.Database.Calibration namespace GSS2.Core.Analysis.AmineContent.Database.Calibration.Migrations
{ {
[DbContext(typeof(AmineContentCalibrationContext))] [DbContext(typeof(AmineContentCalibrationContext))]
partial class AmineContentCalibrationContextModelSnapshot : ModelSnapshot partial class AmineContentCalibrationContextModelSnapshot : ModelSnapshot
@@ -41,7 +41,7 @@ namespace GSS2.Core.Analysis.AmineContent.Database.Calibration
b.Property<double?>("MeasuredContent") b.Property<double?>("MeasuredContent")
.HasColumnType("REAL") .HasColumnType("REAL")
.HasComment("Измеренное колличество масла (кг/т | гр/кг)"); .HasComment("Измеренное количество масла (кг/т | гр/кг)");
b.Property<double?>("MixtureActualRate") b.Property<double?>("MixtureActualRate")
.HasColumnType("REAL") .HasColumnType("REAL")
@@ -100,16 +100,16 @@ namespace GSS2.Core.Analysis.AmineContent.Database.Calibration
.HasColumnType("INTEGER") .HasColumnType("INTEGER")
.HasComment("Уникальный идентификатор"); .HasComment("Уникальный идентификатор");
b.Property<int?>("CalibrationSampleId")
.HasColumnType("INTEGER");
b.Property<string>("ImagePath") b.Property<string>("ImagePath")
.IsRequired() .IsRequired()
.HasMaxLength(1024) .HasMaxLength(1024)
.HasColumnType("TEXT") .HasColumnType("TEXT")
.HasComment("Путь к файлу изображения"); .HasComment("Путь к файлу изображения");
b.Property<int?>("SeparatorRecordId") b.Property<int?>("UsedInCalibrationRecordSampleId")
.HasColumnType("INTEGER");
b.Property<int?>("UsedInSeparatorRecordId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<double>("Uv254Intensity") b.Property<double>("Uv254Intensity")
@@ -126,9 +126,9 @@ namespace GSS2.Core.Analysis.AmineContent.Database.Calibration
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CalibrationSampleId"); b.HasIndex("UsedInCalibrationRecordSampleId");
b.HasIndex("SeparatorRecordId"); b.HasIndex("UsedInSeparatorRecordId");
b.ToTable("ImageRecords"); b.ToTable("ImageRecords");
}); });
@@ -174,19 +174,19 @@ namespace GSS2.Core.Analysis.AmineContent.Database.Calibration
modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.Calibration.ImageRecord", b => modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.Calibration.ImageRecord", b =>
{ {
b.HasOne("GSS2.Core.Analysis.AmineContent.Database.Calibration.CalibrationRecord", "CalibrationSample") b.HasOne("GSS2.Core.Analysis.AmineContent.Database.Calibration.CalibrationRecord", "UsedInCalibrationRecordSample")
.WithMany("SampleImages") .WithMany("SampleImages")
.HasForeignKey("CalibrationSampleId") .HasForeignKey("UsedInCalibrationRecordSampleId")
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
b.HasOne("GSS2.Core.Analysis.AmineContent.Database.Calibration.SeparatorRecord", "Separator") b.HasOne("GSS2.Core.Analysis.AmineContent.Database.Calibration.SeparatorRecord", "UsedInSeparatorRecord")
.WithMany("Images") .WithMany("Images")
.HasForeignKey("SeparatorRecordId") .HasForeignKey("UsedInSeparatorRecordId")
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
b.Navigation("CalibrationSample"); b.Navigation("UsedInCalibrationRecordSample");
b.Navigation("Separator"); b.Navigation("UsedInSeparatorRecord");
}); });
modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.Calibration.CalibrationRecord", b => modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.Calibration.CalibrationRecord", b =>
@@ -8,11 +8,11 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable #nullable disable
namespace GSS2.Core.Analysis.AmineContent.Database.Results namespace GSS2.Core.Analysis.AmineContent.Database.Results.Migrations
{ {
[DbContext(typeof(AmineContentResultsContext))] [DbContext(typeof(AmineContentResultsContext))]
[Migration("20260303084204_AmineContentResultsInitial")] [Migration("20260313083009_AmineContentResults0")]
partial class AmineContentResultsInitial partial class AmineContentResults0
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -3,10 +3,10 @@ using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
namespace GSS2.Core.Analysis.AmineContent.Database.Results namespace GSS2.Core.Analysis.AmineContent.Database.Results.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class AmineContentResultsInitial : Migration public partial class AmineContentResults0 : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
@@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable #nullable disable
namespace GSS2.Core.Analysis.AmineContent.Database.Results namespace GSS2.Core.Analysis.AmineContent.Database.Results.Migrations
{ {
[DbContext(typeof(AmineContentResultsContext))] [DbContext(typeof(AmineContentResultsContext))]
partial class AmineContentResultsContextModelSnapshot : ModelSnapshot partial class AmineContentResultsContextModelSnapshot : ModelSnapshot
+2 -2
View File
@@ -1,2 +1,2 @@
dotnet ef migrations add -o .\Analysis\AmineContent\Database\Calibration --project .\GSS2.Core\ AmineContentCalibrationInitial --context AmineContentCalibrationContext dotnet ef migrations add -o .\Analysis\AmineContent\Database\Calibration\Migrations --project .\GSS2.Core\ AmineContentCalibration0 --context AmineContentCalibrationContext
dotnet ef migrations add -o .\Analysis\AmineContent\Database\Results --project .\GSS2.Core\ AmineContentResultsInitial --context AmineContentResultsContext dotnet ef migrations add -o .\Analysis\AmineContent\Database\Results\Migrations --project .\GSS2.Core\ AmineContentResults0 --context AmineContentResultsContext
+2 -2
View File
@@ -1,2 +1,2 @@
dotnet ef migrations add -o ./Analysis/AmineContent/Database/Calibration --project ./GSS2.Core/ AmineContentCalibrationInitial --context AmineContentCalibrationContext dotnet ef migrations add -o ./Analysis/AmineContent/Database/Calibration/Migrations --project ./GSS2.Core/ AmineContentCalibration0 --context AmineContentCalibrationContext
dotnet ef migrations add -o ./Analysis/AmineContent/Database/Results --project ./GSS2.Core/ AmineContentResultsInitial --context AmineContentResultsContext dotnet ef migrations add -o ./Analysis/AmineContent/Database/Results/Migrations --project ./GSS2.Core/ AmineContentResults0 --context AmineContentResultsContext