forked from ddrilling/AsbCloudServer
Fix WellComposite model FK; WellCompositeService automapping
Rename DrillFlowChartParams to DrillFlowChart
This commit is contained in:
parent
aa977e4db5
commit
91878bda5c
2683
AsbCloudDb/Migrations/20211014082358_Fix_WellComposite_FK.Designer.cs
generated
Normal file
2683
AsbCloudDb/Migrations/20211014082358_Fix_WellComposite_FK.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
46
AsbCloudDb/Migrations/20211014082358_Fix_WellComposite_FK.cs
Normal file
46
AsbCloudDb/Migrations/20211014082358_Fix_WellComposite_FK.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Fix_WellComposite_FK : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "t_well_сomposite_t_well_section_type_id_fk",
|
||||
table: "t_well_сomposite");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_well_сomposite_id_well_section_type",
|
||||
table: "t_well_сomposite",
|
||||
column: "id_well_section_type");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "t_well_сomposite_t_well_section_type_id_fk",
|
||||
table: "t_well_сomposite",
|
||||
column: "id_well_section_type",
|
||||
principalTable: "t_well_section_type",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "t_well_сomposite_t_well_section_type_id_fk",
|
||||
table: "t_well_сomposite");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_t_well_сomposite_id_well_section_type",
|
||||
table: "t_well_сomposite");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "t_well_сomposite_t_well_section_type_id_fk",
|
||||
table: "t_well_сomposite",
|
||||
column: "id_well_src",
|
||||
principalTable: "t_well_section_type",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
2683
AsbCloudDb/Migrations/20211014082448_Rename_DrillFlowChartParams_to_DrillFlowChart.Designer.cs
generated
Normal file
2683
AsbCloudDb/Migrations/20211014082448_Rename_DrillFlowChartParams_to_DrillFlowChart.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,73 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Rename_DrillFlowChartParams_to_DrillFlowChart : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_t_drill_flow_chart_params_t_well_well_id",
|
||||
table: "t_drill_flow_chart_params");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_t_drill_flow_chart_params",
|
||||
table: "t_drill_flow_chart_params");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "t_drill_flow_chart_params",
|
||||
newName: "t_drill_flow_chart");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_t_drill_flow_chart_params_well_id",
|
||||
table: "t_drill_flow_chart",
|
||||
newName: "IX_t_drill_flow_chart_well_id");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_t_drill_flow_chart",
|
||||
table: "t_drill_flow_chart",
|
||||
column: "id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_t_drill_flow_chart_t_well_well_id",
|
||||
table: "t_drill_flow_chart",
|
||||
column: "well_id",
|
||||
principalTable: "t_well",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_t_drill_flow_chart_t_well_well_id",
|
||||
table: "t_drill_flow_chart");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_t_drill_flow_chart",
|
||||
table: "t_drill_flow_chart");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "t_drill_flow_chart",
|
||||
newName: "t_drill_flow_chart_params");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_t_drill_flow_chart_well_id",
|
||||
table: "t_drill_flow_chart_params",
|
||||
newName: "IX_t_drill_flow_chart_params_well_id");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_t_drill_flow_chart_params",
|
||||
table: "t_drill_flow_chart_params",
|
||||
column: "id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_t_drill_flow_chart_params_t_well_well_id",
|
||||
table: "t_drill_flow_chart_params",
|
||||
column: "well_id",
|
||||
principalTable: "t_well",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
@ -156,7 +156,7 @@ namespace AsbCloudDb.Migrations
|
||||
.HasComment("Месторождение");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChartParams", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChart", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -238,7 +238,7 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.HasIndex("IdWell");
|
||||
|
||||
b.ToTable("t_drill_flow_chart_params");
|
||||
b.ToTable("t_drill_flow_chart");
|
||||
|
||||
b
|
||||
.HasComment("Параметры корридоров бурения (диапазоны параметров бурения)");
|
||||
@ -1679,6 +1679,8 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
b.HasKey("IdWell", "IdWellSrc", "IdWellSectionType");
|
||||
|
||||
b.HasIndex("IdWellSectionType");
|
||||
|
||||
b.HasIndex("IdWellSrc");
|
||||
|
||||
b.ToTable("t_well_сomposite");
|
||||
@ -2296,7 +2298,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("CompanyType");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChartParams", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChart", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Well", "Well")
|
||||
.WithMany()
|
||||
@ -2542,6 +2544,13 @@ namespace AsbCloudDb.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
|
||||
.WithMany("WellComposites")
|
||||
.HasForeignKey("IdWellSectionType")
|
||||
.HasConstraintName("t_well_сomposite_t_well_section_type_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.Well", "WellSrc")
|
||||
.WithMany("WellCompositeSrcs")
|
||||
.HasForeignKey("IdWellSrc")
|
||||
@ -2549,13 +2558,6 @@ namespace AsbCloudDb.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
|
||||
.WithMany("WellComposites")
|
||||
.HasForeignKey("IdWellSrc")
|
||||
.HasConstraintName("t_well_сomposite_t_well_section_type_id_fk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Well");
|
||||
|
||||
b.Navigation("WellSectionType");
|
||||
|
@ -92,7 +92,7 @@ namespace AsbCloudDb.Model
|
||||
|
||||
entity.HasOne(d => d.WellSectionType)
|
||||
.WithMany(p => p.WellComposites)
|
||||
.HasForeignKey(d => d.IdWellSrc)
|
||||
.HasForeignKey(d => d.IdWellSectionType)
|
||||
.HasConstraintName("t_well_сomposite_t_well_section_type_id_fk");
|
||||
});
|
||||
|
||||
|
@ -6,7 +6,7 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
[Table("t_drill_flow_chart_params"), Comment("Параметры корридоров бурения (диапазоны параметров бурения)")]
|
||||
[Table("t_drill_flow_chart"), Comment("Параметры корридоров бурения (диапазоны параметров бурения)")]
|
||||
public class DrillFlowChart : IId
|
||||
{
|
||||
[Key]
|
||||
|
@ -35,8 +35,10 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
context.WellComposites.RemoveRange(context.WellComposites
|
||||
.Where(c => c.IdWell == idWell));
|
||||
|
||||
var entities = wellComposites
|
||||
.Adapt<WellComposite>(s => s.IdWell = idWell);
|
||||
.Adapt<WellComposite, WellCompositeDto>((s, d) => { s.IdWell = idWell; });
|
||||
|
||||
context.WellComposites.AddRange(entities);
|
||||
return context.SaveChangesAsync(token);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user