From cb5a6a7916062da4ff5b5772b57f3f6dd56b652c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 05:02:29 +0000 Subject: [PATCH 1/8] Bump follow-redirects from 1.15.3 to 1.15.4 in /src/client Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.4. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.3...v1.15.4) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] --- src/client/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/package-lock.json b/src/client/package-lock.json index 183513fb6..5711538dc 100644 --- a/src/client/package-lock.json +++ b/src/client/package-lock.json @@ -9103,9 +9103,9 @@ "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==" }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.4", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", + "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", "funding": [ { "type": "individual", From 6987e51f9205bf4c5753646a956a3959876fdeb2 Mon Sep 17 00:00:00 2001 From: Frederic Stahel Date: Thu, 11 Jan 2024 08:45:20 +0100 Subject: [PATCH 2/8] Add backfill table --- ...0240111060218_AddBackfillTable.Designer.cs | 2767 +++++++++++++++++ .../20240111060218_AddBackfillTable.cs | 106 + .../Migrations/BdmsContextModelSnapshot.cs | 107 +- src/api/Models/Backfill.cs | 88 + 4 files changed, 3064 insertions(+), 4 deletions(-) create mode 100644 src/api/Migrations/20240111060218_AddBackfillTable.Designer.cs create mode 100644 src/api/Migrations/20240111060218_AddBackfillTable.cs create mode 100644 src/api/Models/Backfill.cs diff --git a/src/api/Migrations/20240111060218_AddBackfillTable.Designer.cs b/src/api/Migrations/20240111060218_AddBackfillTable.Designer.cs new file mode 100644 index 000000000..df0441e45 --- /dev/null +++ b/src/api/Migrations/20240111060218_AddBackfillTable.Designer.cs @@ -0,0 +1,2767 @@ +// +using System; +using BDMS; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using NetTopologySuite.Geometries; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace BDMS.Migrations +{ + [DbContext(typeof(BdmsContext))] + [Migration("20240111060218_AddBackfillTable")] + partial class AddBackfillTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("bdms") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "ltree"); + NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "postgis"); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("BDMS.Models.Backfill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CompletionId") + .HasColumnType("integer") + .HasColumnName("completion_id"); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("creator"); + + b.Property("FromDepth") + .HasColumnType("double precision") + .HasColumnName("from_depth"); + + b.Property("KindId") + .HasColumnType("integer") + .HasColumnName("kind_id"); + + b.Property("MaterialId") + .HasColumnType("integer") + .HasColumnName("material_id"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("ToDepth") + .HasColumnType("double precision") + .HasColumnName("to_depth"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater"); + + b.HasKey("Id"); + + b.HasIndex("CompletionId"); + + b.HasIndex("CreatedById"); + + b.HasIndex("KindId"); + + b.HasIndex("MaterialId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("backfill", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Borehole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_bho"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AlternateName") + .HasColumnType("text") + .HasColumnName("alternate_name_bho"); + + b.Property("Canton") + .HasColumnType("text") + .HasColumnName("canton_bho"); + + b.Property("ChronostratigraphyId") + .HasColumnType("integer") + .HasColumnName("chronostrat_id_cli"); + + b.Property("Country") + .HasColumnType("text") + .HasColumnName("country_bho"); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("created_bho"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("created_by_bho"); + + b.Property("CuttingsId") + .HasColumnType("integer") + .HasColumnName("cuttings_id_cli"); + + b.Property("DrillingDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("drilling_date_bho"); + + b.Property("DrillingDiameter") + .HasColumnType("double precision") + .HasColumnName("drilling_diameter_bho"); + + b.Property("DrillingMethodId") + .HasColumnType("integer") + .HasColumnName("drilling_method_id_cli"); + + b.Property("ElevationZ") + .HasColumnType("double precision") + .HasColumnName("elevation_z_bho"); + + b.Property("Geometry") + .HasColumnType("geometry") + .HasColumnName("geom_bho"); + + b.Property("HasGroundwater") + .HasColumnType("boolean") + .HasColumnName("groundwater_bho"); + + b.Property("HrsId") + .HasColumnType("integer") + .HasColumnName("hrs_id_cli"); + + b.Property("Inclination") + .HasColumnType("double precision") + .HasColumnName("inclination_bho"); + + b.Property("InclinationDirection") + .HasColumnType("double precision") + .HasColumnName("inclination_direction_bho"); + + b.Property("IsPublic") + .HasColumnType("boolean") + .HasColumnName("public_bho"); + + b.Property("KindId") + .HasColumnType("integer") + .HasColumnName("kind_id_cli"); + + b.Property("LithologyTopBedrockId") + .HasColumnType("integer") + .HasColumnName("lithology_top_bedrock_id_cli"); + + b.Property("LithostratigraphyId") + .HasColumnType("integer") + .HasColumnName("lithostrat_id_cli"); + + b.Property("LocationX") + .HasColumnType("double precision") + .HasColumnName("location_x_bho"); + + b.Property("LocationXLV03") + .HasColumnType("double precision") + .HasColumnName("location_x_lv03_bho"); + + b.Property("LocationY") + .HasColumnType("double precision") + .HasColumnName("location_y_bho"); + + b.Property("LocationYLV03") + .HasColumnType("double precision") + .HasColumnName("location_y_lv03_bho"); + + b.Property("Locked") + .HasColumnType("timestamp with time zone") + .HasColumnName("locked_bho"); + + b.Property("LockedById") + .HasColumnType("integer") + .HasColumnName("locked_by_bho"); + + b.Property("Municipality") + .HasColumnType("text") + .HasColumnName("municipality_bho"); + + b.Property("NationalInterest") + .HasColumnType("boolean") + .HasColumnName("national_interest"); + + b.Property("OriginalName") + .HasColumnType("text") + .HasColumnName("original_name_bho"); + + b.Property("OriginalReferenceSystem") + .HasColumnType("integer") + .HasColumnName("srs_id_cli"); + + b.Property("ProjectName") + .HasColumnType("text") + .HasColumnName("project_name_bho"); + + b.Property("PurposeId") + .HasColumnType("integer") + .HasColumnName("purpose_id_cli"); + + b.Property("QtDepthId") + .HasColumnType("integer") + .HasColumnName("qt_depth_id_cli"); + + b.Property("QtElevationId") + .HasColumnType("integer") + .HasColumnName("qt_elevation_id_cli"); + + b.Property("QtInclinationDirectionId") + .HasColumnType("integer") + .HasColumnName("qt_inclination_direction_id_cli"); + + b.Property("QtLocationId") + .HasColumnType("integer") + .HasColumnName("qt_location_id_cli"); + + b.Property("QtReferenceElevationId") + .HasColumnType("integer") + .HasColumnName("qt_reference_elevation_id_cli"); + + b.Property("QtTopBedrock") + .HasColumnType("double precision") + .HasColumnName("qt_top_bedrock"); + + b.Property("QtTopBedrockTvd") + .HasColumnType("double precision") + .HasColumnName("qt_top_bedrock_tvd"); + + b.Property("QtTotalDepthTvdId") + .HasColumnType("integer") + .HasColumnName("qt_total_depth_tvd_id_cli"); + + b.Property("ReferenceElevation") + .HasColumnType("double precision") + .HasColumnName("reference_elevation_bho"); + + b.Property("ReferenceElevationTypeId") + .HasColumnType("integer") + .HasColumnName("reference_elevation_type_id_cli"); + + b.Property("Remarks") + .HasColumnType("text") + .HasColumnName("remarks_bho"); + + b.Property("RestrictionId") + .HasColumnType("integer") + .HasColumnName("restriction_id_cli"); + + b.Property("RestrictionUntil") + .HasColumnType("timestamp with time zone") + .HasColumnName("restriction_until_bho"); + + b.Property("SpudDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("spud_date_bho"); + + b.Property("StatusId") + .HasColumnType("integer") + .HasColumnName("status_id_cli"); + + b.Property("TopBedrock") + .HasColumnType("double precision") + .HasColumnName("top_bedrock_bho"); + + b.Property("TopBedrockTvd") + .HasColumnType("double precision") + .HasColumnName("top_bedrock_tvd_bho"); + + b.Property("TotalDepth") + .HasColumnType("double precision") + .HasColumnName("total_depth_bho"); + + b.Property("TotalDepthTvd") + .HasColumnType("double precision") + .HasColumnName("total_depth_tvd_bho"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_bho"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updated_by_bho"); + + b.Property("WorkgroupId") + .HasColumnType("integer") + .HasColumnName("id_wgp_fk"); + + b.HasKey("Id"); + + b.HasIndex("ChronostratigraphyId"); + + b.HasIndex("CreatedById"); + + b.HasIndex("CuttingsId"); + + b.HasIndex("DrillingMethodId"); + + b.HasIndex("HrsId"); + + b.HasIndex("KindId"); + + b.HasIndex("LithologyTopBedrockId"); + + b.HasIndex("LithostratigraphyId"); + + b.HasIndex("LockedById"); + + b.HasIndex("PurposeId"); + + b.HasIndex("QtDepthId"); + + b.HasIndex("QtElevationId"); + + b.HasIndex("QtInclinationDirectionId"); + + b.HasIndex("QtLocationId"); + + b.HasIndex("QtReferenceElevationId"); + + b.HasIndex("QtTotalDepthTvdId"); + + b.HasIndex("ReferenceElevationTypeId"); + + b.HasIndex("RestrictionId"); + + b.HasIndex("StatusId"); + + b.HasIndex("UpdatedById"); + + b.HasIndex("WorkgroupId"); + + b.ToTable("borehole", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.BoreholeCodelist", b => + { + b.Property("BoreholeId") + .HasColumnType("integer") + .HasColumnName("id_bho_fk"); + + b.Property("CodelistId") + .HasColumnType("integer") + .HasColumnName("id_cli_fk"); + + b.Property("SchemaName") + .IsRequired() + .HasColumnType("text") + .HasColumnName("code_cli"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text") + .HasColumnName("value_bco"); + + b.HasKey("BoreholeId", "CodelistId"); + + b.HasIndex("CodelistId"); + + b.ToTable("borehole_codelist", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.BoreholeFile", b => + { + b.Property("BoreholeId") + .HasColumnType("integer") + .HasColumnName("id_bho_fk"); + + b.Property("FileId") + .HasColumnType("integer") + .HasColumnName("id_fil_fk"); + + b.Property("Attached") + .HasColumnType("timestamp with time zone") + .HasColumnName("attached_bfi"); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("created_bfi"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("created_by_bfi"); + + b.Property("Description") + .HasColumnType("text") + .HasColumnName("description_bfi"); + + b.Property("Public") + .HasColumnType("boolean") + .HasColumnName("public_bfi"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update_bfi"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater_bfi"); + + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("id_usr_fk"); + + b.HasKey("BoreholeId", "FileId"); + + b.HasIndex("CreatedById"); + + b.HasIndex("FileId"); + + b.HasIndex("UpdatedById"); + + b.HasIndex("UserId"); + + b.ToTable("borehole_files", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.ChronostratigraphyLayer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_chr"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChronostratigraphyId") + .HasColumnType("integer") + .HasColumnName("chronostratigraphy_id"); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("creator"); + + b.Property("FromDepth") + .HasColumnType("double precision") + .HasColumnName("depth_from"); + + b.Property("IsLast") + .HasColumnType("boolean") + .HasColumnName("is_last"); + + b.Property("StratigraphyId") + .HasColumnType("integer") + .HasColumnName("id_sty_fk"); + + b.Property("ToDepth") + .HasColumnType("double precision") + .HasColumnName("depth_to"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater"); + + b.HasKey("Id"); + + b.HasIndex("ChronostratigraphyId"); + + b.HasIndex("CreatedById"); + + b.HasIndex("StratigraphyId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("chronostratigraphy", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Codelist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_cli"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasColumnType("text") + .HasColumnName("code_cli"); + + b.Property("Conf") + .HasColumnType("text") + .HasColumnName("conf_cli"); + + b.Property("De") + .HasColumnType("text") + .HasColumnName("text_cli_de"); + + b.Property("DescriptionDe") + .HasColumnType("text") + .HasColumnName("description_cli_de"); + + b.Property("DescriptionEn") + .IsRequired() + .HasColumnType("text") + .HasColumnName("description_cli_en"); + + b.Property("DescriptionFr") + .HasColumnType("text") + .HasColumnName("description_cli_fr"); + + b.Property("DescriptionIt") + .HasColumnType("text") + .HasColumnName("description_cli_it"); + + b.Property("DescriptionRo") + .HasColumnType("text") + .HasColumnName("description_cli_ro"); + + b.Property("En") + .IsRequired() + .HasColumnType("text") + .HasColumnName("text_cli_en"); + + b.Property("Fr") + .HasColumnType("text") + .HasColumnName("text_cli_fr"); + + b.Property("Geolcode") + .HasColumnType("integer") + .HasColumnName("geolcode"); + + b.Property("IsDefault") + .HasColumnType("boolean") + .HasColumnName("default_cli"); + + b.Property("It") + .HasColumnType("text") + .HasColumnName("text_cli_it"); + + b.Property("Order") + .HasColumnType("integer") + .HasColumnName("order_cli"); + + b.Property("Path") + .HasColumnType("ltree") + .HasColumnName("path_cli"); + + b.Property("Ro") + .HasColumnType("text") + .HasColumnName("text_cli_ro"); + + b.Property("Schema") + .HasColumnType("text") + .HasColumnName("schema_cli"); + + b.HasKey("Id"); + + b.ToTable("codelist", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Completion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AbandonDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("abandon_date"); + + b.Property("BoreholeId") + .HasColumnType("integer") + .HasColumnName("borehole_id"); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("creator"); + + b.Property("IsPrimary") + .HasColumnType("boolean") + .HasColumnName("is_primary"); + + b.Property("KindId") + .HasColumnType("integer") + .HasColumnName("kind_id"); + + b.Property("Name") + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater"); + + b.HasKey("Id"); + + b.HasIndex("BoreholeId"); + + b.HasIndex("CreatedById"); + + b.HasIndex("KindId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("completion", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Config", b => + { + b.Property("Name") + .HasColumnType("text") + .HasColumnName("name_cfg"); + + b.Property("Value") + .HasColumnType("text") + .HasColumnName("value_cfg"); + + b.HasKey("Name"); + + b.ToTable("config", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Content", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_cnt"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Creation") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation_cnt"); + + b.Property("Expired") + .HasColumnType("timestamp with time zone") + .HasColumnName("expired_cnt"); + + b.Property("IsDraft") + .HasColumnType("boolean") + .HasColumnName("draft_cnt"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name_cnt"); + + b.Property("TextDe") + .HasColumnType("text") + .HasColumnName("text_cnt_de"); + + b.Property("TextEn") + .HasColumnType("text") + .HasColumnName("text_cnt_en"); + + b.Property("TextFr") + .HasColumnType("text") + .HasColumnName("text_cnt_fr"); + + b.Property("TextIt") + .HasColumnType("text") + .HasColumnName("text_cnt_it"); + + b.Property("TextRo") + .HasColumnType("text") + .HasColumnName("text_cnt_ro"); + + b.Property("TitelRo") + .HasColumnType("text") + .HasColumnName("title_cnt_ro"); + + b.Property("TitleDe") + .HasColumnType("text") + .HasColumnName("title_cnt_de"); + + b.Property("TitleEn") + .HasColumnType("text") + .HasColumnName("title_cnt_en"); + + b.Property("TitleFr") + .HasColumnType("text") + .HasColumnName("title_cnt_fr"); + + b.Property("TitleIt") + .HasColumnType("text") + .HasColumnName("title_cnt_it"); + + b.HasKey("Id"); + + b.ToTable("contents", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.FaciesDescription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_fac"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("creator"); + + b.Property("Description") + .HasColumnType("text") + .HasColumnName("description"); + + b.Property("FromDepth") + .HasColumnType("double precision") + .HasColumnName("depth_from"); + + b.Property("IsLast") + .HasColumnType("boolean") + .HasColumnName("is_last"); + + b.Property("QtDescriptionId") + .HasColumnType("integer") + .HasColumnName("qt_description_id"); + + b.Property("StratigraphyId") + .HasColumnType("integer") + .HasColumnName("id_sty_fk"); + + b.Property("ToDepth") + .HasColumnType("double precision") + .HasColumnName("depth_to"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("QtDescriptionId"); + + b.HasIndex("StratigraphyId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("facies_description", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Feedback", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_feb"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("created_feb"); + + b.Property("IsFrw") + .HasColumnType("boolean") + .HasColumnName("frw_feb"); + + b.Property("Message") + .HasColumnType("text") + .HasColumnName("message_feb"); + + b.Property("Tag") + .HasColumnType("text") + .HasColumnName("tag_feb"); + + b.Property("User") + .IsRequired() + .HasColumnType("text") + .HasColumnName("user_feb"); + + b.HasKey("Id"); + + b.ToTable("feedbacks", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.File", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_fil"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("uploaded_fil"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("id_usr_fk"); + + b.Property("Hash") + .IsRequired() + .HasColumnType("text") + .HasColumnName("hash_fil"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name_fil"); + + b.Property("NameUuid") + .HasColumnType("text") + .HasColumnName("name_uuid_fil"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text") + .HasColumnName("type_fil"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_fil"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updated_by_fil"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("UpdatedById"); + + b.ToTable("files", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.HydrotestCodelist", b => + { + b.Property("HydrotestId") + .HasColumnType("integer") + .HasColumnName("id_ht_fk"); + + b.Property("CodelistId") + .HasColumnType("integer") + .HasColumnName("id_cli_fk"); + + b.HasKey("HydrotestId", "CodelistId"); + + b.HasIndex("CodelistId"); + + b.ToTable("hydrotest_codelist", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.HydrotestResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("creator"); + + b.Property("HydrotestId") + .HasColumnType("integer") + .HasColumnName("hydrotest_id"); + + b.Property("MaxValue") + .HasColumnType("double precision") + .HasColumnName("max_value"); + + b.Property("MinValue") + .HasColumnType("double precision") + .HasColumnName("min_value"); + + b.Property("ParameterId") + .HasColumnType("integer") + .HasColumnName("parameter"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater"); + + b.Property("Value") + .HasColumnType("double precision") + .HasColumnName("value"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("HydrotestId"); + + b.HasIndex("ParameterId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("hydrotest_result", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Instrumentation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CompletionId") + .HasColumnType("integer") + .HasColumnName("completion_id"); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("creator"); + + b.Property("FromDepth") + .HasColumnType("double precision") + .HasColumnName("from_depth"); + + b.Property("KindId") + .HasColumnType("integer") + .HasColumnName("kind_id"); + + b.Property("Name") + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("StatusId") + .HasColumnType("integer") + .HasColumnName("status_id"); + + b.Property("ToDepth") + .HasColumnType("double precision") + .HasColumnName("to_depth"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater"); + + b.HasKey("Id"); + + b.HasIndex("CompletionId"); + + b.HasIndex("CreatedById"); + + b.HasIndex("KindId"); + + b.HasIndex("StatusId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("instrumentation", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Layer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_lay"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AlterationId") + .HasColumnType("integer") + .HasColumnName("alteration_id_cli"); + + b.Property("Casing") + .HasColumnType("text") + .HasColumnName("casng_id"); + + b.Property("CasingDateFinish") + .HasColumnType("timestamp with time zone") + .HasColumnName("casng_date_finish_lay"); + + b.Property("CasingDateSpud") + .HasColumnType("timestamp with time zone") + .HasColumnName("casng_date_spud_lay"); + + b.Property("CasingInnerDiameter") + .HasColumnType("double precision") + .HasColumnName("casng_inner_diameter_lay"); + + b.Property("CasingKindId") + .HasColumnType("integer") + .HasColumnName("casng_kind_id_cli"); + + b.Property("CasingMaterialId") + .HasColumnType("integer") + .HasColumnName("casng_material_id_cli"); + + b.Property("CasingOuterDiameter") + .HasColumnType("double precision") + .HasColumnName("casng_outer_diameter_lay"); + + b.Property("CohesionId") + .HasColumnType("integer") + .HasColumnName("cohesion_id_cli"); + + b.Property("CompactnessId") + .HasColumnType("integer") + .HasColumnName("compactness_id_cli"); + + b.Property("ConsistanceId") + .HasColumnType("integer") + .HasColumnName("consistance_id_cli"); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation_lay"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("creator_lay"); + + b.Property("FillKindId") + .HasColumnType("integer") + .HasColumnName("fill_kind_id_cli"); + + b.Property("FillMaterialId") + .HasColumnType("integer") + .HasColumnName("fill_material_id_cli"); + + b.Property("FromDepth") + .HasColumnType("double precision") + .HasColumnName("depth_from_lay"); + + b.Property("GradationId") + .HasColumnType("integer") + .HasColumnName("gradation_id_cli"); + + b.Property("GrainSize1Id") + .HasColumnType("integer") + .HasColumnName("grain_size_1_id_cli"); + + b.Property("GrainSize2Id") + .HasColumnType("integer") + .HasColumnName("grain_size_2_id_cli"); + + b.Property("HumidityId") + .HasColumnType("integer") + .HasColumnName("humidity_id_cli"); + + b.Property("Instrument") + .HasColumnType("text") + .HasColumnName("instr_id"); + + b.Property("InstrumentCasingId") + .HasColumnType("integer") + .HasColumnName("instr_id_sty_fk"); + + b.Property("InstrumentCasingLayerId") + .HasColumnType("integer") + .HasColumnName("instr_id_lay_fk"); + + b.Property("InstrumentKindId") + .HasColumnType("integer") + .HasColumnName("instr_kind_id_cli"); + + b.Property("InstrumentStatusId") + .HasColumnType("integer") + .HasColumnName("instr_status_id_cli"); + + b.Property("IsLast") + .HasColumnType("boolean") + .HasColumnName("last_lay"); + + b.Property("IsStriae") + .HasColumnType("boolean") + .HasColumnName("striae_lay"); + + b.Property("IsUndefined") + .HasColumnType("boolean") + .HasColumnName("undefined_lay"); + + b.Property("LithologyId") + .HasColumnType("integer") + .HasColumnName("lithology_id_cli"); + + b.Property("LithologyTopBedrockId") + .HasColumnType("integer") + .HasColumnName("lithology_top_bedrock_id_cli"); + + b.Property("LithostratigraphyId") + .HasColumnType("integer") + .HasColumnName("lithostratigraphy_id_cli"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes_lay"); + + b.Property("OriginalLithology") + .HasColumnType("text") + .HasColumnName("original_lithology"); + + b.Property("OriginalUscs") + .HasColumnType("text") + .HasColumnName("uscs_original_lay"); + + b.Property("PlasticityId") + .HasColumnType("integer") + .HasColumnName("plasticity_id_cli"); + + b.Property("QtDescriptionId") + .HasColumnType("integer") + .HasColumnName("qt_description_id_cli"); + + b.Property("StratigraphyId") + .HasColumnType("integer") + .HasColumnName("id_sty_fk"); + + b.Property("ToDepth") + .HasColumnType("double precision") + .HasColumnName("depth_to_lay"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update_lay"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater_lay"); + + b.Property("Uscs1Id") + .HasColumnType("integer") + .HasColumnName("uscs_1_id_cli"); + + b.Property("Uscs2Id") + .HasColumnType("integer") + .HasColumnName("uscs_2_id_cli"); + + b.Property("UscsDeterminationId") + .HasColumnType("integer") + .HasColumnName("uscs_determination_id_cli"); + + b.HasKey("Id"); + + b.HasIndex("AlterationId"); + + b.HasIndex("CasingKindId"); + + b.HasIndex("CasingMaterialId"); + + b.HasIndex("CohesionId"); + + b.HasIndex("CompactnessId"); + + b.HasIndex("ConsistanceId"); + + b.HasIndex("CreatedById"); + + b.HasIndex("FillKindId"); + + b.HasIndex("FillMaterialId"); + + b.HasIndex("GradationId"); + + b.HasIndex("GrainSize1Id"); + + b.HasIndex("GrainSize2Id"); + + b.HasIndex("HumidityId"); + + b.HasIndex("InstrumentCasingId"); + + b.HasIndex("InstrumentKindId"); + + b.HasIndex("InstrumentStatusId"); + + b.HasIndex("LithologyId"); + + b.HasIndex("LithologyTopBedrockId"); + + b.HasIndex("LithostratigraphyId"); + + b.HasIndex("PlasticityId"); + + b.HasIndex("QtDescriptionId"); + + b.HasIndex("StratigraphyId"); + + b.HasIndex("UpdatedById"); + + b.HasIndex("Uscs1Id"); + + b.HasIndex("Uscs2Id"); + + b.HasIndex("UscsDeterminationId"); + + b.ToTable("layer", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.LayerCodelist", b => + { + b.Property("LayerId") + .HasColumnType("integer") + .HasColumnName("id_lay_fk"); + + b.Property("CodelistId") + .HasColumnType("integer") + .HasColumnName("id_cli_fk"); + + b.Property("SchemaName") + .IsRequired() + .HasColumnType("text") + .HasColumnName("code_cli"); + + b.HasKey("LayerId", "CodelistId"); + + b.HasIndex("CodelistId"); + + b.ToTable("layer_codelist", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.LithologicalDescription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_ldp"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("creator"); + + b.Property("Description") + .HasColumnType("text") + .HasColumnName("description"); + + b.Property("FromDepth") + .HasColumnType("double precision") + .HasColumnName("depth_from"); + + b.Property("IsLast") + .HasColumnType("boolean") + .HasColumnName("is_last"); + + b.Property("QtDescriptionId") + .HasColumnType("integer") + .HasColumnName("qt_description_id"); + + b.Property("StratigraphyId") + .HasColumnType("integer") + .HasColumnName("id_sty_fk"); + + b.Property("ToDepth") + .HasColumnType("double precision") + .HasColumnName("depth_to"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("QtDescriptionId"); + + b.HasIndex("StratigraphyId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("lithological_description", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.LithostratigraphyLayer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("creator"); + + b.Property("FromDepth") + .HasColumnType("double precision") + .HasColumnName("depth_from"); + + b.Property("IsLast") + .HasColumnType("boolean") + .HasColumnName("is_last"); + + b.Property("LithostratigraphyId") + .HasColumnType("integer") + .HasColumnName("lithostratigraphy_id"); + + b.Property("StratigraphyId") + .HasColumnType("integer") + .HasColumnName("stratigraphy_id"); + + b.Property("ToDepth") + .HasColumnType("double precision") + .HasColumnName("depth_to"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("LithostratigraphyId"); + + b.HasIndex("StratigraphyId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("lithostratigraphy", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Observation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BoreholeId") + .HasColumnType("integer") + .HasColumnName("borehole_id"); + + b.Property("CasingId") + .HasColumnType("integer") + .HasColumnName("casing"); + + b.Property("Comment") + .HasColumnType("text") + .HasColumnName("comment"); + + b.Property("CompletionFinished") + .HasColumnType("boolean") + .HasColumnName("completion_finished"); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("creator"); + + b.Property("Duration") + .HasColumnType("double precision") + .HasColumnName("duration"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone") + .HasColumnName("end_time"); + + b.Property("FromDepthM") + .HasColumnType("double precision") + .HasColumnName("from_depth_m"); + + b.Property("FromDepthMasl") + .HasColumnType("double precision") + .HasColumnName("from_depth_masl"); + + b.Property("ReliabilityId") + .HasColumnType("integer") + .HasColumnName("reliability"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone") + .HasColumnName("start_time"); + + b.Property("ToDepthM") + .HasColumnType("double precision") + .HasColumnName("to_depth_m"); + + b.Property("ToDepthMasl") + .HasColumnType("double precision") + .HasColumnName("to_depth_masl"); + + b.Property("Type") + .HasColumnType("integer") + .HasColumnName("observation_type"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater"); + + b.HasKey("Id"); + + b.HasIndex("BoreholeId"); + + b.HasIndex("CasingId"); + + b.HasIndex("CreatedById"); + + b.HasIndex("ReliabilityId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("observation", "bdms"); + + b.UseTptMappingStrategy(); + }); + + modelBuilder.Entity("BDMS.Models.Stratigraphy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_sty"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BoreholeId") + .HasColumnType("integer") + .HasColumnName("id_bho_fk"); + + b.Property("Casing") + .HasColumnType("text") + .HasColumnName("casng_id"); + + b.Property("CasingDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("casng_date_abd_sty"); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation_sty"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("author_sty"); + + b.Property("Date") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_sty"); + + b.Property("FillCasingId") + .HasColumnType("integer") + .HasColumnName("fill_casng_id_sty_fk"); + + b.Property("IsPrimary") + .HasColumnType("boolean") + .HasColumnName("primary_sty"); + + b.Property("KindId") + .HasColumnType("integer") + .HasColumnName("kind_id_cli"); + + b.Property("Name") + .HasColumnType("text") + .HasColumnName("name_sty"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes_sty"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update_sty"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater_sty"); + + b.HasKey("Id"); + + b.HasIndex("BoreholeId"); + + b.HasIndex("CreatedById"); + + b.HasIndex("FillCasingId"); + + b.HasIndex("KindId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("stratigraphy", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Term", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_tes"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Creation") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation_tes"); + + b.Property("Expiration") + .HasColumnType("timestamp with time zone") + .HasColumnName("expired_tes"); + + b.Property("IsDraft") + .HasColumnType("boolean") + .HasColumnName("draft_tes"); + + b.Property("TextDe") + .HasColumnType("text") + .HasColumnName("text_tes_de"); + + b.Property("TextEn") + .IsRequired() + .HasColumnType("text") + .HasColumnName("text_tes_en"); + + b.Property("TextFr") + .HasColumnType("text") + .HasColumnName("text_tes_fr"); + + b.Property("TextIt") + .HasColumnType("text") + .HasColumnName("text_tes_it"); + + b.Property("TextRo") + .HasColumnType("text") + .HasColumnName("text_tes_ro"); + + b.HasKey("Id"); + + b.ToTable("terms", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_usr"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DisabledAt") + .HasColumnType("timestamp with time zone") + .HasColumnName("disabled_usr"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text") + .HasColumnName("firstname"); + + b.Property("IsAdmin") + .HasColumnType("boolean") + .HasColumnName("admin_usr"); + + b.Property("IsViewer") + .HasColumnType("boolean") + .HasColumnName("viewer_usr"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text") + .HasColumnName("lastname"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("username"); + + b.HasKey("Id"); + + b.ToTable("users", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.UserEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_evs"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("created_evs"); + + b.Property("Payload") + .HasColumnType("jsonb") + .HasColumnName("payload_evs"); + + b.Property("Topic") + .IsRequired() + .HasColumnType("text") + .HasColumnName("topic_evs"); + + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("id_usr_fk"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("events", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.UserWorkgroupRole", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("id_usr_fk"); + + b.Property("WorkgroupId") + .HasColumnType("integer") + .HasColumnName("id_wgp_fk"); + + b.Property("Role") + .HasColumnType("int") + .HasColumnName("id_rol_fk"); + + b.HasKey("UserId", "WorkgroupId", "Role"); + + b.ToTable("users_roles", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Workflow", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_wkf"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BoreholeId") + .HasColumnType("integer") + .HasColumnName("id_bho_fk"); + + b.Property("Finished") + .HasColumnType("timestamp with time zone") + .HasColumnName("finished_wkf"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes_wkf"); + + b.Property("Role") + .HasColumnType("integer") + .HasColumnName("id_rol_fk"); + + b.Property("Started") + .HasColumnType("timestamp with time zone") + .HasColumnName("started_wkf"); + + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("id_usr_fk"); + + b.HasKey("Id"); + + b.HasIndex("BoreholeId"); + + b.HasIndex("UserId"); + + b.ToTable("workflow", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Workgroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id_wgp"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("created_wgp"); + + b.Property("Disabled") + .HasColumnType("timestamp with time zone") + .HasColumnName("disabled_wgp"); + + b.Property("IsSupplier") + .HasColumnType("boolean") + .HasColumnName("supplier_wgp"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name_wgp"); + + b.Property("Settings") + .HasColumnType("json") + .HasColumnName("settings_wgp"); + + b.HasKey("Id"); + + b.ToTable("workgroups", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.FieldMeasurement", b => + { + b.HasBaseType("BDMS.Models.Observation"); + + b.Property("ParameterId") + .HasColumnType("integer") + .HasColumnName("parameter"); + + b.Property("SampleTypeId") + .HasColumnType("integer") + .HasColumnName("sample_type"); + + b.Property("Value") + .HasColumnType("double precision") + .HasColumnName("value"); + + b.HasIndex("ParameterId"); + + b.HasIndex("SampleTypeId"); + + b.ToTable("field_measurement", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.GroundwaterLevelMeasurement", b => + { + b.HasBaseType("BDMS.Models.Observation"); + + b.Property("KindId") + .HasColumnType("integer") + .HasColumnName("kind"); + + b.Property("LevelM") + .HasColumnType("double precision") + .HasColumnName("level_m"); + + b.Property("LevelMasl") + .HasColumnType("double precision") + .HasColumnName("level_masl"); + + b.HasIndex("KindId"); + + b.ToTable("groundwater_level_measurement", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Hydrotest", b => + { + b.HasBaseType("BDMS.Models.Observation"); + + b.ToTable("hydrotest", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.WaterIngress", b => + { + b.HasBaseType("BDMS.Models.Observation"); + + b.Property("ConditionsId") + .HasColumnType("integer") + .HasColumnName("conditions"); + + b.Property("QuantityId") + .HasColumnType("integer") + .HasColumnName("quantity"); + + b.HasIndex("ConditionsId"); + + b.HasIndex("QuantityId"); + + b.ToTable("water_ingress", "bdms"); + }); + + modelBuilder.Entity("BDMS.Models.Backfill", b => + { + b.HasOne("BDMS.Models.Completion", "Completion") + .WithMany() + .HasForeignKey("CompletionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Codelist", "Kind") + .WithMany() + .HasForeignKey("KindId"); + + b.HasOne("BDMS.Models.Codelist", "Material") + .WithMany() + .HasForeignKey("MaterialId"); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("Completion"); + + b.Navigation("CreatedBy"); + + b.Navigation("Kind"); + + b.Navigation("Material"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("BDMS.Models.Borehole", b => + { + b.HasOne("BDMS.Models.Codelist", "Chronostratigraphy") + .WithMany() + .HasForeignKey("ChronostratigraphyId"); + + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Codelist", "Cuttings") + .WithMany() + .HasForeignKey("CuttingsId"); + + b.HasOne("BDMS.Models.Codelist", "DrillingMethod") + .WithMany() + .HasForeignKey("DrillingMethodId"); + + b.HasOne("BDMS.Models.Codelist", "Hrs") + .WithMany() + .HasForeignKey("HrsId"); + + b.HasOne("BDMS.Models.Codelist", "Kind") + .WithMany() + .HasForeignKey("KindId"); + + b.HasOne("BDMS.Models.Codelist", "LithologyTopBedrock") + .WithMany() + .HasForeignKey("LithologyTopBedrockId"); + + b.HasOne("BDMS.Models.Codelist", "Lithostratigraphy") + .WithMany() + .HasForeignKey("LithostratigraphyId"); + + b.HasOne("BDMS.Models.User", "LockedBy") + .WithMany() + .HasForeignKey("LockedById"); + + b.HasOne("BDMS.Models.Codelist", "Purpose") + .WithMany() + .HasForeignKey("PurposeId"); + + b.HasOne("BDMS.Models.Codelist", "QtDepth") + .WithMany() + .HasForeignKey("QtDepthId"); + + b.HasOne("BDMS.Models.Codelist", "QtElevation") + .WithMany() + .HasForeignKey("QtElevationId"); + + b.HasOne("BDMS.Models.Codelist", "QtInclinationDirection") + .WithMany() + .HasForeignKey("QtInclinationDirectionId"); + + b.HasOne("BDMS.Models.Codelist", "QtLocation") + .WithMany() + .HasForeignKey("QtLocationId"); + + b.HasOne("BDMS.Models.Codelist", "QtReferenceElevation") + .WithMany() + .HasForeignKey("QtReferenceElevationId"); + + b.HasOne("BDMS.Models.Codelist", "QtTotalDepthTvd") + .WithMany() + .HasForeignKey("QtTotalDepthTvdId"); + + b.HasOne("BDMS.Models.Codelist", "ReferenceElevationType") + .WithMany() + .HasForeignKey("ReferenceElevationTypeId"); + + b.HasOne("BDMS.Models.Codelist", "Restriction") + .WithMany() + .HasForeignKey("RestrictionId"); + + b.HasOne("BDMS.Models.Codelist", "Status") + .WithMany() + .HasForeignKey("StatusId"); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.HasOne("BDMS.Models.Workgroup", "Workgroup") + .WithMany("Boreholes") + .HasForeignKey("WorkgroupId"); + + b.Navigation("Chronostratigraphy"); + + b.Navigation("CreatedBy"); + + b.Navigation("Cuttings"); + + b.Navigation("DrillingMethod"); + + b.Navigation("Hrs"); + + b.Navigation("Kind"); + + b.Navigation("LithologyTopBedrock"); + + b.Navigation("Lithostratigraphy"); + + b.Navigation("LockedBy"); + + b.Navigation("Purpose"); + + b.Navigation("QtDepth"); + + b.Navigation("QtElevation"); + + b.Navigation("QtInclinationDirection"); + + b.Navigation("QtLocation"); + + b.Navigation("QtReferenceElevation"); + + b.Navigation("QtTotalDepthTvd"); + + b.Navigation("ReferenceElevationType"); + + b.Navigation("Restriction"); + + b.Navigation("Status"); + + b.Navigation("UpdatedBy"); + + b.Navigation("Workgroup"); + }); + + modelBuilder.Entity("BDMS.Models.BoreholeCodelist", b => + { + b.HasOne("BDMS.Models.Borehole", "Borehole") + .WithMany("BoreholeCodelists") + .HasForeignKey("BoreholeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.Codelist", "Codelist") + .WithMany("BoreholeCodelists") + .HasForeignKey("CodelistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Borehole"); + + b.Navigation("Codelist"); + }); + + modelBuilder.Entity("BDMS.Models.BoreholeFile", b => + { + b.HasOne("BDMS.Models.Borehole", "Borehole") + .WithMany("BoreholeFiles") + .HasForeignKey("BoreholeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.File", "File") + .WithMany("BoreholeFiles") + .HasForeignKey("FileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.HasOne("BDMS.Models.User", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Borehole"); + + b.Navigation("CreatedBy"); + + b.Navigation("File"); + + b.Navigation("UpdatedBy"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("BDMS.Models.ChronostratigraphyLayer", b => + { + b.HasOne("BDMS.Models.Codelist", "Chronostratigraphy") + .WithMany() + .HasForeignKey("ChronostratigraphyId"); + + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Stratigraphy", "Stratigraphy") + .WithMany("ChronostratigraphyLayers") + .HasForeignKey("StratigraphyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("Chronostratigraphy"); + + b.Navigation("CreatedBy"); + + b.Navigation("Stratigraphy"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("BDMS.Models.Completion", b => + { + b.HasOne("BDMS.Models.Borehole", "Borehole") + .WithMany() + .HasForeignKey("BoreholeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Codelist", "Kind") + .WithMany() + .HasForeignKey("KindId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("Borehole"); + + b.Navigation("CreatedBy"); + + b.Navigation("Kind"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("BDMS.Models.FaciesDescription", b => + { + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Codelist", "QtDescription") + .WithMany() + .HasForeignKey("QtDescriptionId"); + + b.HasOne("BDMS.Models.Stratigraphy", "Stratigraphy") + .WithMany("FaciesDescriptions") + .HasForeignKey("StratigraphyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + + b.Navigation("QtDescription"); + + b.Navigation("Stratigraphy"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("BDMS.Models.File", b => + { + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("BDMS.Models.HydrotestCodelist", b => + { + b.HasOne("BDMS.Models.Codelist", "Codelist") + .WithMany("HydrotestCodelists") + .HasForeignKey("CodelistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.Hydrotest", "Hydrotest") + .WithMany("HydrotestCodelists") + .HasForeignKey("HydrotestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Codelist"); + + b.Navigation("Hydrotest"); + }); + + modelBuilder.Entity("BDMS.Models.HydrotestResult", b => + { + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Hydrotest", "Hydrotest") + .WithMany("HydrotestResults") + .HasForeignKey("HydrotestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.Codelist", "Parameter") + .WithMany() + .HasForeignKey("ParameterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + + b.Navigation("Hydrotest"); + + b.Navigation("Parameter"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("BDMS.Models.Instrumentation", b => + { + b.HasOne("BDMS.Models.Completion", "Completion") + .WithMany() + .HasForeignKey("CompletionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Codelist", "Kind") + .WithMany() + .HasForeignKey("KindId"); + + b.HasOne("BDMS.Models.Codelist", "Status") + .WithMany() + .HasForeignKey("StatusId"); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("Completion"); + + b.Navigation("CreatedBy"); + + b.Navigation("Kind"); + + b.Navigation("Status"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("BDMS.Models.Layer", b => + { + b.HasOne("BDMS.Models.Codelist", "Alteration") + .WithMany() + .HasForeignKey("AlterationId"); + + b.HasOne("BDMS.Models.Codelist", "CasingKind") + .WithMany() + .HasForeignKey("CasingKindId"); + + b.HasOne("BDMS.Models.Codelist", "CasingMaterial") + .WithMany() + .HasForeignKey("CasingMaterialId"); + + b.HasOne("BDMS.Models.Codelist", "Cohesion") + .WithMany() + .HasForeignKey("CohesionId"); + + b.HasOne("BDMS.Models.Codelist", "Compactness") + .WithMany() + .HasForeignKey("CompactnessId"); + + b.HasOne("BDMS.Models.Codelist", "Consistance") + .WithMany() + .HasForeignKey("ConsistanceId"); + + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Codelist", "FillKind") + .WithMany() + .HasForeignKey("FillKindId"); + + b.HasOne("BDMS.Models.Codelist", "FillMaterial") + .WithMany() + .HasForeignKey("FillMaterialId"); + + b.HasOne("BDMS.Models.Codelist", "Gradation") + .WithMany() + .HasForeignKey("GradationId"); + + b.HasOne("BDMS.Models.Codelist", "GrainSize1") + .WithMany() + .HasForeignKey("GrainSize1Id"); + + b.HasOne("BDMS.Models.Codelist", "GrainSize2") + .WithMany() + .HasForeignKey("GrainSize2Id"); + + b.HasOne("BDMS.Models.Codelist", "Humidity") + .WithMany() + .HasForeignKey("HumidityId"); + + b.HasOne("BDMS.Models.Stratigraphy", "InstrumentCasing") + .WithMany() + .HasForeignKey("InstrumentCasingId"); + + b.HasOne("BDMS.Models.Codelist", "InstrumentKind") + .WithMany() + .HasForeignKey("InstrumentKindId"); + + b.HasOne("BDMS.Models.Codelist", "InstrumentStatus") + .WithMany() + .HasForeignKey("InstrumentStatusId"); + + b.HasOne("BDMS.Models.Codelist", "Lithology") + .WithMany() + .HasForeignKey("LithologyId"); + + b.HasOne("BDMS.Models.Codelist", "LithologyTopBedrock") + .WithMany() + .HasForeignKey("LithologyTopBedrockId"); + + b.HasOne("BDMS.Models.Codelist", "Lithostratigraphy") + .WithMany() + .HasForeignKey("LithostratigraphyId"); + + b.HasOne("BDMS.Models.Codelist", "Plasticity") + .WithMany() + .HasForeignKey("PlasticityId"); + + b.HasOne("BDMS.Models.Codelist", "QtDescription") + .WithMany() + .HasForeignKey("QtDescriptionId"); + + b.HasOne("BDMS.Models.Stratigraphy", "Stratigraphy") + .WithMany("Layers") + .HasForeignKey("StratigraphyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.HasOne("BDMS.Models.Codelist", "Uscs1") + .WithMany() + .HasForeignKey("Uscs1Id"); + + b.HasOne("BDMS.Models.Codelist", "Uscs2") + .WithMany() + .HasForeignKey("Uscs2Id"); + + b.HasOne("BDMS.Models.Codelist", "UscsDetermination") + .WithMany() + .HasForeignKey("UscsDeterminationId"); + + b.Navigation("Alteration"); + + b.Navigation("CasingKind"); + + b.Navigation("CasingMaterial"); + + b.Navigation("Cohesion"); + + b.Navigation("Compactness"); + + b.Navigation("Consistance"); + + b.Navigation("CreatedBy"); + + b.Navigation("FillKind"); + + b.Navigation("FillMaterial"); + + b.Navigation("Gradation"); + + b.Navigation("GrainSize1"); + + b.Navigation("GrainSize2"); + + b.Navigation("Humidity"); + + b.Navigation("InstrumentCasing"); + + b.Navigation("InstrumentKind"); + + b.Navigation("InstrumentStatus"); + + b.Navigation("Lithology"); + + b.Navigation("LithologyTopBedrock"); + + b.Navigation("Lithostratigraphy"); + + b.Navigation("Plasticity"); + + b.Navigation("QtDescription"); + + b.Navigation("Stratigraphy"); + + b.Navigation("UpdatedBy"); + + b.Navigation("Uscs1"); + + b.Navigation("Uscs2"); + + b.Navigation("UscsDetermination"); + }); + + modelBuilder.Entity("BDMS.Models.LayerCodelist", b => + { + b.HasOne("BDMS.Models.Codelist", "Codelist") + .WithMany("LayerCodelists") + .HasForeignKey("CodelistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.Layer", "Layer") + .WithMany("LayerCodelists") + .HasForeignKey("LayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Codelist"); + + b.Navigation("Layer"); + }); + + modelBuilder.Entity("BDMS.Models.LithologicalDescription", b => + { + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Codelist", "QtDescription") + .WithMany() + .HasForeignKey("QtDescriptionId"); + + b.HasOne("BDMS.Models.Stratigraphy", "Stratigraphy") + .WithMany("LithologicalDescriptions") + .HasForeignKey("StratigraphyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + + b.Navigation("QtDescription"); + + b.Navigation("Stratigraphy"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("BDMS.Models.LithostratigraphyLayer", b => + { + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Codelist", "Lithostratigraphy") + .WithMany() + .HasForeignKey("LithostratigraphyId"); + + b.HasOne("BDMS.Models.Stratigraphy", "Stratigraphy") + .WithMany("LithostratigraphyLayers") + .HasForeignKey("StratigraphyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + + b.Navigation("Lithostratigraphy"); + + b.Navigation("Stratigraphy"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("BDMS.Models.Observation", b => + { + b.HasOne("BDMS.Models.Borehole", "Borehole") + .WithMany() + .HasForeignKey("BoreholeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.Stratigraphy", "Casing") + .WithMany() + .HasForeignKey("CasingId"); + + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Codelist", "Reliability") + .WithMany() + .HasForeignKey("ReliabilityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("Borehole"); + + b.Navigation("Casing"); + + b.Navigation("CreatedBy"); + + b.Navigation("Reliability"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("BDMS.Models.Stratigraphy", b => + { + b.HasOne("BDMS.Models.Borehole", "Borehole") + .WithMany("Stratigraphies") + .HasForeignKey("BoreholeId"); + + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Stratigraphy", "FillCasing") + .WithMany() + .HasForeignKey("FillCasingId"); + + b.HasOne("BDMS.Models.Codelist", "Kind") + .WithMany() + .HasForeignKey("KindId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("Borehole"); + + b.Navigation("CreatedBy"); + + b.Navigation("FillCasing"); + + b.Navigation("Kind"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("BDMS.Models.UserEvent", b => + { + b.HasOne("BDMS.Models.User", "User") + .WithMany("BoringEvents") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("BDMS.Models.UserWorkgroupRole", b => + { + b.HasOne("BDMS.Models.User", null) + .WithMany("WorkgroupRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BDMS.Models.Workflow", b => + { + b.HasOne("BDMS.Models.Borehole", "Borehole") + .WithMany("Workflows") + .HasForeignKey("BoreholeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Borehole"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("BDMS.Models.FieldMeasurement", b => + { + b.HasOne("BDMS.Models.Observation", null) + .WithOne() + .HasForeignKey("BDMS.Models.FieldMeasurement", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.Codelist", "Parameter") + .WithMany() + .HasForeignKey("ParameterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.Codelist", "SampleType") + .WithMany() + .HasForeignKey("SampleTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parameter"); + + b.Navigation("SampleType"); + }); + + modelBuilder.Entity("BDMS.Models.GroundwaterLevelMeasurement", b => + { + b.HasOne("BDMS.Models.Observation", null) + .WithOne() + .HasForeignKey("BDMS.Models.GroundwaterLevelMeasurement", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.Codelist", "Kind") + .WithMany() + .HasForeignKey("KindId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Kind"); + }); + + modelBuilder.Entity("BDMS.Models.Hydrotest", b => + { + b.HasOne("BDMS.Models.Observation", null) + .WithOne() + .HasForeignKey("BDMS.Models.Hydrotest", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BDMS.Models.WaterIngress", b => + { + b.HasOne("BDMS.Models.Codelist", "Conditions") + .WithMany() + .HasForeignKey("ConditionsId"); + + b.HasOne("BDMS.Models.Observation", null) + .WithOne() + .HasForeignKey("BDMS.Models.WaterIngress", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.Codelist", "Quantity") + .WithMany() + .HasForeignKey("QuantityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Conditions"); + + b.Navigation("Quantity"); + }); + + modelBuilder.Entity("BDMS.Models.Borehole", b => + { + b.Navigation("BoreholeCodelists"); + + b.Navigation("BoreholeFiles"); + + b.Navigation("Stratigraphies"); + + b.Navigation("Workflows"); + }); + + modelBuilder.Entity("BDMS.Models.Codelist", b => + { + b.Navigation("BoreholeCodelists"); + + b.Navigation("HydrotestCodelists"); + + b.Navigation("LayerCodelists"); + }); + + modelBuilder.Entity("BDMS.Models.File", b => + { + b.Navigation("BoreholeFiles"); + }); + + modelBuilder.Entity("BDMS.Models.Layer", b => + { + b.Navigation("LayerCodelists"); + }); + + modelBuilder.Entity("BDMS.Models.Stratigraphy", b => + { + b.Navigation("ChronostratigraphyLayers"); + + b.Navigation("FaciesDescriptions"); + + b.Navigation("Layers"); + + b.Navigation("LithologicalDescriptions"); + + b.Navigation("LithostratigraphyLayers"); + }); + + modelBuilder.Entity("BDMS.Models.User", b => + { + b.Navigation("BoringEvents"); + + b.Navigation("WorkgroupRoles"); + }); + + modelBuilder.Entity("BDMS.Models.Workgroup", b => + { + b.Navigation("Boreholes"); + }); + + modelBuilder.Entity("BDMS.Models.Hydrotest", b => + { + b.Navigation("HydrotestCodelists"); + + b.Navigation("HydrotestResults"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/api/Migrations/20240111060218_AddBackfillTable.cs b/src/api/Migrations/20240111060218_AddBackfillTable.cs new file mode 100644 index 000000000..6005dd31f --- /dev/null +++ b/src/api/Migrations/20240111060218_AddBackfillTable.cs @@ -0,0 +1,106 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace BDMS.Migrations; + +/// +public partial class AddBackfillTable : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "backfill", + schema: "bdms", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + completion_id = table.Column(type: "integer", nullable: false), + from_depth = table.Column(type: "double precision", nullable: true), + to_depth = table.Column(type: "double precision", nullable: true), + kind_id = table.Column(type: "integer", nullable: true), + material_id = table.Column(type: "integer", nullable: true), + notes = table.Column(type: "text", nullable: true), + creator = table.Column(type: "integer", nullable: true), + creation = table.Column(type: "timestamp with time zone", nullable: true), + updater = table.Column(type: "integer", nullable: true), + update = table.Column(type: "timestamp with time zone", nullable: true), + }, + constraints: table => + { + table.PrimaryKey("PK_backfill", x => x.id); + table.ForeignKey( + name: "FK_backfill_codelist_kind_id", + column: x => x.kind_id, + principalSchema: "bdms", + principalTable: "codelist", + principalColumn: "id_cli"); + table.ForeignKey( + name: "FK_backfill_codelist_material_id", + column: x => x.material_id, + principalSchema: "bdms", + principalTable: "codelist", + principalColumn: "id_cli"); + table.ForeignKey( + name: "FK_backfill_completion_completion_id", + column: x => x.completion_id, + principalSchema: "bdms", + principalTable: "completion", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_backfill_users_creator", + column: x => x.creator, + principalSchema: "bdms", + principalTable: "users", + principalColumn: "id_usr"); + table.ForeignKey( + name: "FK_backfill_users_updater", + column: x => x.updater, + principalSchema: "bdms", + principalTable: "users", + principalColumn: "id_usr"); + }); + + migrationBuilder.CreateIndex( + name: "IX_backfill_completion_id", + schema: "bdms", + table: "backfill", + column: "completion_id"); + + migrationBuilder.CreateIndex( + name: "IX_backfill_creator", + schema: "bdms", + table: "backfill", + column: "creator"); + + migrationBuilder.CreateIndex( + name: "IX_backfill_kind_id", + schema: "bdms", + table: "backfill", + column: "kind_id"); + + migrationBuilder.CreateIndex( + name: "IX_backfill_material_id", + schema: "bdms", + table: "backfill", + column: "material_id"); + + migrationBuilder.CreateIndex( + name: "IX_backfill_updater", + schema: "bdms", + table: "backfill", + column: "updater"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "backfill", + schema: "bdms"); + } +} diff --git a/src/api/Migrations/BdmsContextModelSnapshot.cs b/src/api/Migrations/BdmsContextModelSnapshot.cs index 81c4911f0..808b5be5e 100644 --- a/src/api/Migrations/BdmsContextModelSnapshot.cs +++ b/src/api/Migrations/BdmsContextModelSnapshot.cs @@ -26,6 +26,70 @@ protected override void BuildModel(ModelBuilder modelBuilder) NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "postgis"); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("BDMS.Models.Backfill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CompletionId") + .HasColumnType("integer") + .HasColumnName("completion_id"); + + b.Property("Created") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation"); + + b.Property("CreatedById") + .HasColumnType("integer") + .HasColumnName("creator"); + + b.Property("FromDepth") + .HasColumnType("double precision") + .HasColumnName("from_depth"); + + b.Property("KindId") + .HasColumnType("integer") + .HasColumnName("kind_id"); + + b.Property("MaterialId") + .HasColumnType("integer") + .HasColumnName("material_id"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("ToDepth") + .HasColumnType("double precision") + .HasColumnName("to_depth"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone") + .HasColumnName("update"); + + b.Property("UpdatedById") + .HasColumnType("integer") + .HasColumnName("updater"); + + b.HasKey("Id"); + + b.HasIndex("CompletionId"); + + b.HasIndex("CreatedById"); + + b.HasIndex("KindId"); + + b.HasIndex("MaterialId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("backfill", "bdms"); + }); + modelBuilder.Entity("BDMS.Models.Borehole", b => { b.Property("Id") @@ -921,14 +985,14 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("double precision") .HasColumnName("from_depth"); - b.Property("Name") - .HasColumnType("text") - .HasColumnName("name"); - b.Property("KindId") .HasColumnType("integer") .HasColumnName("kind_id"); + b.Property("Name") + .HasColumnType("text") + .HasColumnName("name"); + b.Property("Notes") .HasColumnType("text") .HasColumnName("notes"); @@ -1801,6 +1865,41 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("water_ingress", "bdms"); }); + modelBuilder.Entity("BDMS.Models.Backfill", b => + { + b.HasOne("BDMS.Models.Completion", "Completion") + .WithMany() + .HasForeignKey("CompletionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BDMS.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("BDMS.Models.Codelist", "Kind") + .WithMany() + .HasForeignKey("KindId"); + + b.HasOne("BDMS.Models.Codelist", "Material") + .WithMany() + .HasForeignKey("MaterialId"); + + b.HasOne("BDMS.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("Completion"); + + b.Navigation("CreatedBy"); + + b.Navigation("Kind"); + + b.Navigation("Material"); + + b.Navigation("UpdatedBy"); + }); + modelBuilder.Entity("BDMS.Models.Borehole", b => { b.HasOne("BDMS.Models.Codelist", "Chronostratigraphy") diff --git a/src/api/Models/Backfill.cs b/src/api/Models/Backfill.cs new file mode 100644 index 000000000..392dd45b8 --- /dev/null +++ b/src/api/Models/Backfill.cs @@ -0,0 +1,88 @@ +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System.ComponentModel.DataAnnotations.Schema; + +namespace BDMS.Models; + +/// +/// Represents a Backfill entity in the database. +/// +[Table("backfill")] +public class Backfill : IChangeTracking, IIdentifyable +{ + /// + [Column("id")] + public int Id { get; set; } + + /// + /// Gets or sets foreign key for the of this . + /// + [Column("completion_id")] + public int CompletionId { get; set; } + + /// + /// Gets or sets the of this . + /// + public Completion? Completion { get; set; } + + /// + /// Gets or sets the 's upper depth. + /// + [Column("from_depth")] + public double? FromDepth { get; set; } + + /// + /// Gets or sets the 's lower depth. + /// + [Column("to_depth")] + public double? ToDepth { get; set; } + + /// + /// Gets or sets the id 's kind. + /// + [Column("kind_id")] + public int? KindId { get; set; } + + /// + /// Gets or sets the 's kind. + /// + public Codelist? Kind { get; set; } + + /// + /// Gets or sets the id of the 's status. + /// + [Column("material_id")] + public int? MaterialId { get; set; } + + /// + /// Gets or sets the 's status. + /// + public Codelist? Material { get; set; } + + /// + /// Gets or sets the 's notes. + /// + [Column("notes")] + public string? Notes { get; set; } + + /// + [Column("creator")] + public int? CreatedById { get; set; } + + /// + public User? CreatedBy { get; set; } + + /// + [Column("creation")] + public DateTime? Created { get; set; } + + /// + [Column("updater")] + public int? UpdatedById { get; set; } + + /// + public User? UpdatedBy { get; set; } + + /// + [Column("update")] + public DateTime? Updated { get; set; } +} From ffb22c1cc802bee1befd09f985b894c736679de3 Mon Sep 17 00:00:00 2001 From: Frederic Stahel Date: Thu, 11 Jan 2024 08:45:30 +0100 Subject: [PATCH 3/8] Add backfill controller --- src/api/Controllers/BackfillController.cs | 78 +++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/api/Controllers/BackfillController.cs diff --git a/src/api/Controllers/BackfillController.cs b/src/api/Controllers/BackfillController.cs new file mode 100644 index 000000000..037f7a2a9 --- /dev/null +++ b/src/api/Controllers/BackfillController.cs @@ -0,0 +1,78 @@ +using BDMS.Authentication; +using BDMS.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace BDMS.Controllers; + +[ApiController] +[Route("api/v{version:apiVersion}/[controller]")] +public class BackfillController : BdmsControllerBase +{ + private readonly BdmsContext context; + + public BackfillController(BdmsContext context, ILogger logger) + : base(context, logger) + { + this.context = context; + } + + /// + /// Asynchronously gets the s, optionally filtered by . + /// + /// The id of the completion containing the to get. + [HttpGet] + [Authorize(Policy = PolicyNames.Viewer)] + public async Task> GetAsync([FromQuery] int? completionId = null) + { + var backfills = context.Backfills + .Include(i => i.Material) + .Include(i => i.Kind) + .AsNoTracking(); + + if (completionId != null) + { + backfills = backfills.Where(i => i.CompletionId == completionId); + } + + return await backfills.ToListAsync().ConfigureAwait(false); + } + + /// + /// Asynchronously gets the with the specified . + /// + [HttpGet("{id}")] + [Authorize(Policy = PolicyNames.Viewer)] + public async Task> GetByIdAsync(int id) + { + var backfill = await context.Backfills + .Include(i => i.Material) + .Include(i => i.Kind) + .AsNoTracking() + .SingleOrDefaultAsync(i => i.Id == id) + .ConfigureAwait(false); + + if (backfill == null) + { + return NotFound(); + } + + return Ok(backfill); + } + + /// + [Authorize(Policy = PolicyNames.Viewer)] + public override Task> CreateAsync(Backfill entity) + => base.CreateAsync(entity); + + /// + [Authorize(Policy = PolicyNames.Viewer)] + public override Task> EditAsync(Backfill entity) + => base.EditAsync(entity); + + /// + [Authorize(Policy = PolicyNames.Viewer)] + public override Task DeleteAsync(int id) + => base.DeleteAsync(id); +} From 628729263724b4bc01765c6e6d2912d3ab7a9f35 Mon Sep 17 00:00:00 2001 From: Frederic Stahel Date: Thu, 11 Jan 2024 08:45:55 +0100 Subject: [PATCH 4/8] Add backfill tests --- src/api/BdmsContext.cs | 1 + src/api/BdmsContextExtensions.cs | 41 +++++- src/api/Models/CompletionSchemas.cs | 2 + tests/Controllers/BackfillControllerTest.cs | 131 ++++++++++++++++++++ 4 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 tests/Controllers/BackfillControllerTest.cs diff --git a/src/api/BdmsContext.cs b/src/api/BdmsContext.cs index f8d90ec5a..4594d133a 100644 --- a/src/api/BdmsContext.cs +++ b/src/api/BdmsContext.cs @@ -37,6 +37,7 @@ public class BdmsContext : DbContext public DbSet FieldMeasurements { get; set; } public DbSet Completions { get; set; } public DbSet Instrumentations { get; set; } + public DbSet Backfills { get; set; } public BdmsContext(DbContextOptions options) : base(options) diff --git a/src/api/BdmsContextExtensions.cs b/src/api/BdmsContextExtensions.cs index 7c437b156..3380d682a 100644 --- a/src/api/BdmsContextExtensions.cs +++ b/src/api/BdmsContextExtensions.cs @@ -85,8 +85,8 @@ public static void SeedData(this BdmsContext context) List humidityIds = codelists.Where(c => c.Schema == "mlpr105").Select(s => s.Id).ToList(); List alterationIds = codelists.Where(c => c.Schema == "mlpr106").Select(s => s.Id).ToList(); List cohesionIds = codelists.Where(c => c.Schema == "mlpr116").Select(s => s.Id).ToList(); - List fillKindIds = codelists.Where(c => c.Schema == "fill100").Select(s => s.Id).ToList(); - List fillMaterialIds = codelists.Where(c => c.Schema == "fill200").Select(s => s.Id).ToList(); + List backfillKindIds = codelists.Where(c => c.Schema == CompletionSchemas.BackfillKindSchema).Select(s => s.Id).ToList(); + List backfillMaterialIds = codelists.Where(c => c.Schema == CompletionSchemas.BackfillMaterialSchema).Select(s => s.Id).ToList(); List uscsIds = codelists.Where(c => c.Schema == "mcla101").Select(s => s.Id).ToList(); List uscsDeterminationIds = codelists.Where(c => c.Schema == "mcla104").Select(s => s.Id).ToList(); List gradationIds = codelists.Where(c => c.Schema == "gradation").Select(s => s.Id).ToList(); @@ -340,9 +340,9 @@ int GetStratigraphyOrCasingId(int currentLayerId, int startId) .RuleFor(o => o.CreatedBy, _ => default!) .RuleFor(o => o.UpdatedById, f => f.PickRandom(userRange)) .RuleFor(o => o.UpdatedBy, _ => default!) - .RuleFor(o => o.FillKindId, f => f.PickRandom(fillKindIds).OrNull(f, .05f)) + .RuleFor(o => o.FillKindId, f => f.PickRandom(backfillKindIds).OrNull(f, .05f)) .RuleFor(o => o.FillKind, _ => default!) - .RuleFor(o => o.FillMaterialId, f => f.PickRandom(fillMaterialIds).OrNull(f, .05f)) + .RuleFor(o => o.FillMaterialId, f => f.PickRandom(backfillMaterialIds).OrNull(f, .05f)) .RuleFor(o => o.FillMaterial, _ => default!) .RuleFor(o => o.GradationId, f => f.PickRandom(gradationIds).OrNull(f, .05f)) .RuleFor(o => o.Gradation, f => default!) @@ -757,6 +757,39 @@ Instrumentation SeedeInstrumentation(Completion completion) context.SaveChanges(); + // Seed Backfill + var backfill_ids = 16_000_000; + var fakeBackfill = new Faker() + .RuleFor(b => b.CompletionId, f => f.PickRandom(completions.Select(c => c.Id))) + .RuleFor(b => b.Completion, _ => default!) + .RuleFor(b => b.FromDepth, f => (backfill_ids % 10) * 10) + .RuleFor(b => b.ToDepth, f => ((backfill_ids % 10) + 1) * 10) + .RuleFor(b => b.KindId, f => f.PickRandom(backfillKindIds)) + .RuleFor(b => b.Kind, _ => default!) + .RuleFor(b => b.MaterialId, f => f.PickRandom(backfillMaterialIds)) + .RuleFor(b => b.Material, _ => default!) + .RuleFor(i => i.Notes, f => f.Random.Words(4)) + .RuleFor(i => i.Created, f => f.Date.Past().ToUniversalTime()) + .RuleFor(i => i.CreatedById, f => f.PickRandom(userRange)) + .RuleFor(i => i.CreatedBy, _ => default!) + .RuleFor(i => i.Updated, f => f.Date.Past().ToUniversalTime()) + .RuleFor(i => i.UpdatedById, f => f.PickRandom(userRange)) + .RuleFor(i => i.UpdatedBy, _ => default!) + .RuleFor(i => i.Id, f => backfill_ids++); + + Backfill SeedeBackfill(Completion completion) + { + return fakeBackfill + .UseSeed(completion.Id) + .Generate(); + } + + var backfills = completions.Select(c => SeedeBackfill(c)).ToList(); + + context.BulkInsert(backfills, bulkConfig); + + context.SaveChanges(); + // Sync all database sequences context.Database.ExecuteSqlInterpolated($"SELECT setval(pg_get_serial_sequence('bdms.workgroups', 'id_wgp'), {workgroup_ids - 1})"); context.Database.ExecuteSqlInterpolated($"SELECT setval(pg_get_serial_sequence('bdms.borehole', 'id_bho'), {borehole_ids - 1})"); diff --git a/src/api/Models/CompletionSchemas.cs b/src/api/Models/CompletionSchemas.cs index 08ebbe19a..50b033493 100644 --- a/src/api/Models/CompletionSchemas.cs +++ b/src/api/Models/CompletionSchemas.cs @@ -8,4 +8,6 @@ public static class CompletionSchemas public const string CompletionKindSchema = "completion_kind"; public const string InstrumentationKindSchema = "inst100"; public const string InstrumentationStatusSchema = "inst101"; + public const string BackfillKindSchema = "fill100"; + public const string BackfillMaterialSchema = "fill200"; } diff --git a/tests/Controllers/BackfillControllerTest.cs b/tests/Controllers/BackfillControllerTest.cs new file mode 100644 index 000000000..ac5500a34 --- /dev/null +++ b/tests/Controllers/BackfillControllerTest.cs @@ -0,0 +1,131 @@ +using BDMS.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Moq; + +namespace BDMS.Controllers; + +[TestClass] +public class BackfillControllerTest +{ + private BdmsContext context; + private BackfillController controller; + + [TestInitialize] + public void TestInitialize() + { + context = ContextFactory.GetTestContext(); + controller = new BackfillController(context, new Mock>().Object); + controller.ControllerContext.HttpContext = new DefaultHttpContext(); + } + + [TestCleanup] + public async Task TestCleanup() + { + await context.DisposeAsync(); + } + + [TestMethod] + public async Task GetAsync() + { + IEnumerable? backfills = await controller.GetAsync().ConfigureAwait(false); + Assert.IsNotNull(backfills); + Assert.AreEqual(500, backfills.Count()); + } + + [TestMethod] + public async Task GetAsyncFilterByCompletionId() + { + // Precondition: Find a group of two backfills with the same completion id. + var completions = await context.Backfills.ToListAsync(); + var completionId = completions + .GroupBy(i => i.CompletionId) + .Where(g => g.Count() == 2) + .First().Key; + + IEnumerable? backfills = await controller.GetAsync(completionId).ConfigureAwait(false); + Assert.IsNotNull(backfills); + Assert.AreEqual(2, backfills.Count()); + } + + [TestMethod] + public async Task GetByIdAsync() + { + var backfillId = context.Backfills.First().Id; + + var response = await controller.GetByIdAsync(backfillId).ConfigureAwait(false); + var backfill = ActionResultAssert.IsOkObjectResult(response.Result); + Assert.AreEqual(backfillId, backfill.Id); + } + + [TestMethod] + public async Task CreateAsync() + { + var completionId = context.Completions.First().Id; + var backfill = new Backfill() + { + CompletionId = completionId, + MaterialId = context.Codelists.First(c => c.Schema == CompletionSchemas.BackfillMaterialSchema).Id, + KindId = context.Codelists.First(c => c.Schema == CompletionSchemas.BackfillKindSchema).Id, + Notes = "ARGONSHIP", + FromDepth = 0, + ToDepth = 100, + }; + + var response = await controller.CreateAsync(backfill); + ActionResultAssert.IsOkObjectResult(response.Result); + + backfill = await context.Backfills.FindAsync(backfill.Id); + Assert.IsNotNull(backfill); + Assert.AreEqual(completionId, backfill.CompletionId); + Assert.AreEqual("ARGONSHIP", backfill.Notes); + Assert.AreEqual(0, backfill.FromDepth); + Assert.AreEqual(100, backfill.ToDepth); + Assert.AreEqual(context.Codelists.First(c => c.Schema == CompletionSchemas.BackfillMaterialSchema).Id, backfill.MaterialId); + Assert.AreEqual(context.Codelists.First(c => c.Schema == CompletionSchemas.BackfillKindSchema).Id, backfill.KindId); + } + + [TestMethod] + public async Task EditAsync() + { + var backfill = context.Backfills.First(); + var completionId = backfill.CompletionId; + + backfill.MaterialId = context.Codelists.First(c => c.Schema == CompletionSchemas.BackfillMaterialSchema).Id; + backfill.KindId = context.Codelists.First(c => c.Schema == CompletionSchemas.BackfillKindSchema).Id; + backfill.Notes = "COLLAR"; + backfill.FromDepth = 50; + backfill.ToDepth = 200; + + var response = await controller.EditAsync(backfill); + ActionResultAssert.IsOkObjectResult(response.Result); + + backfill = await context.Backfills.FindAsync(backfill.Id); + Assert.IsNotNull(backfill); + Assert.AreEqual(completionId, backfill.CompletionId); + Assert.AreEqual("COLLAR", backfill.Notes); + Assert.AreEqual(50, backfill.FromDepth); + Assert.AreEqual(200, backfill.ToDepth); + Assert.AreEqual(context.Codelists.First(c => c.Schema == CompletionSchemas.BackfillMaterialSchema).Id, backfill.MaterialId); + Assert.AreEqual(context.Codelists.First(c => c.Schema == CompletionSchemas.BackfillKindSchema).Id, backfill.KindId); + } + + [TestMethod] + public async Task DeleteBackfill() + { + var backfill = context.Backfills.First(); + + var completionCount = context.Completions.Count(); + var backfillCount = context.Backfills.Count(); + + var response = await controller.DeleteAsync(backfill.Id); + ActionResultAssert.IsOk(response); + + backfill = await context.Backfills.FindAsync(backfill.Id); + Assert.IsNull(backfill); + Assert.AreEqual(completionCount, context.Completions.Count()); + Assert.AreEqual(backfillCount - 1, context.Backfills.Count()); + } +} From 55ddcff749fe25ec2704c219622129644ba1613a Mon Sep 17 00:00:00 2001 From: Frederic Stahel Date: Thu, 11 Jan 2024 08:47:20 +0100 Subject: [PATCH 5/8] Increase sql command timeout for dev env to ensure seed does not encounter a timeout. --- src/api/appsettings.Development.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/appsettings.Development.json b/src/api/appsettings.Development.json index 2c102edfd..0dc67551d 100644 --- a/src/api/appsettings.Development.json +++ b/src/api/appsettings.Development.json @@ -6,7 +6,7 @@ } }, "ConnectionStrings": { - "BdmsContext": "Host=localhost;Username=SPAWNPLOW;Password=YELLOWSPATULA;Database=bdms" + "BdmsContext": "Host=localhost;Username=SPAWNPLOW;Password=YELLOWSPATULA;Database=bdms;CommandTimeout=0;" }, "S3": { "ACCESS_KEY": "REDSQUIRREL", From 2290ce9eb15b6d05a4682ccbda8fddd8a335b4a5 Mon Sep 17 00:00:00 2001 From: Frederic Stahel Date: Thu, 11 Jan 2024 09:19:21 +0100 Subject: [PATCH 6/8] Fix typos --- src/api/BdmsContextExtensions.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/BdmsContextExtensions.cs b/src/api/BdmsContextExtensions.cs index 3380d682a..649e0de8b 100644 --- a/src/api/BdmsContextExtensions.cs +++ b/src/api/BdmsContextExtensions.cs @@ -744,14 +744,14 @@ FieldMeasurement SeededFieldMeasurements(Observation observation) .RuleFor(i => i.UpdatedBy, _ => default!) .RuleFor(i => i.Id, f => instrumentation_ids++); - Instrumentation SeedeInstrumentation(Completion completion) + Instrumentation SeededInstrumentation(Completion completion) { return fakeInstrumentation .UseSeed(completion.Id) .Generate(); } - var instrumentations = completions.Select(c => SeedeInstrumentation(c)).ToList(); + var instrumentations = completions.Select(c => SeededInstrumentation(c)).ToList(); context.BulkInsert(instrumentations, bulkConfig); @@ -777,14 +777,14 @@ Instrumentation SeedeInstrumentation(Completion completion) .RuleFor(i => i.UpdatedBy, _ => default!) .RuleFor(i => i.Id, f => backfill_ids++); - Backfill SeedeBackfill(Completion completion) + Backfill SeededBackfill(Completion completion) { return fakeBackfill .UseSeed(completion.Id) .Generate(); } - var backfills = completions.Select(c => SeedeBackfill(c)).ToList(); + var backfills = completions.Select(c => SeededBackfill(c)).ToList(); context.BulkInsert(backfills, bulkConfig); From 2b4f1da8a410cb82c1728675d48d4e2ccf811b98 Mon Sep 17 00:00:00 2001 From: Frederic Stahel Date: Fri, 12 Jan 2024 10:20:26 +0100 Subject: [PATCH 7/8] Remove unnecessary readonly fields --- src/api/Controllers/BackfillController.cs | 7 ++----- src/api/Controllers/InstrumentationController.cs | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/api/Controllers/BackfillController.cs b/src/api/Controllers/BackfillController.cs index 037f7a2a9..d2ff9ca7c 100644 --- a/src/api/Controllers/BackfillController.cs +++ b/src/api/Controllers/BackfillController.cs @@ -10,12 +10,9 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class BackfillController : BdmsControllerBase { - private readonly BdmsContext context; - public BackfillController(BdmsContext context, ILogger logger) : base(context, logger) { - this.context = context; } /// @@ -26,7 +23,7 @@ public BackfillController(BdmsContext context, ILogger logger) [Authorize(Policy = PolicyNames.Viewer)] public async Task> GetAsync([FromQuery] int? completionId = null) { - var backfills = context.Backfills + var backfills = Context.Backfills .Include(i => i.Material) .Include(i => i.Kind) .AsNoTracking(); @@ -46,7 +43,7 @@ public async Task> GetAsync([FromQuery] int? completionId [Authorize(Policy = PolicyNames.Viewer)] public async Task> GetByIdAsync(int id) { - var backfill = await context.Backfills + var backfill = await Context.Backfills .Include(i => i.Material) .Include(i => i.Kind) .AsNoTracking() diff --git a/src/api/Controllers/InstrumentationController.cs b/src/api/Controllers/InstrumentationController.cs index 86f88a110..1e2a5a8fa 100644 --- a/src/api/Controllers/InstrumentationController.cs +++ b/src/api/Controllers/InstrumentationController.cs @@ -10,12 +10,9 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class InstrumentationController : BdmsControllerBase { - private readonly BdmsContext context; - public InstrumentationController(BdmsContext context, ILogger logger) : base(context, logger) { - this.context = context; } /// @@ -26,7 +23,7 @@ public InstrumentationController(BdmsContext context, ILogger l [Authorize(Policy = PolicyNames.Viewer)] public async Task> GetAsync([FromQuery] int? completionId = null) { - var instrumentations = context.Instrumentations + var instrumentations = Context.Instrumentations .Include(i => i.Status) .Include(i => i.Kind) .AsNoTracking(); @@ -46,7 +43,7 @@ public async Task> GetAsync([FromQuery] int? comple [Authorize(Policy = PolicyNames.Viewer)] public async Task> GetByIdAsync(int id) { - var instrumentation = await context.Instrumentations + var instrumentation = await Context.Instrumentations .Include(i => i.Status) .Include(i => i.Kind) .AsNoTracking() From 83ce685eedd43329ebb917667e4f1d6aad7cdf4f Mon Sep 17 00:00:00 2001 From: Frederic Stahel Date: Fri, 12 Jan 2024 10:20:57 +0100 Subject: [PATCH 8/8] Remove sql command timeout --- src/api/appsettings.Development.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/appsettings.Development.json b/src/api/appsettings.Development.json index 0dc67551d..6f87b7a96 100644 --- a/src/api/appsettings.Development.json +++ b/src/api/appsettings.Development.json @@ -6,7 +6,7 @@ } }, "ConnectionStrings": { - "BdmsContext": "Host=localhost;Username=SPAWNPLOW;Password=YELLOWSPATULA;Database=bdms;CommandTimeout=0;" + "BdmsContext": "Host=localhost;Username=SPAWNPLOW;Password=YELLOWSPATULA;Database=bdms;" }, "S3": { "ACCESS_KEY": "REDSQUIRREL",