From 8bd61cd7ee06604f001db8adb22396116f315dde Mon Sep 17 00:00:00 2001 From: Gwendolyn Date: Sat, 19 Nov 2022 22:18:15 +0100 Subject: [PATCH] remove cities for now --- Migrations/20221115170737_Initial.Designer.cs | 385 ++++++++++++++++++ Migrations/20221115170737_Initial.cs | 276 +++++++++++++ Migrations/AppDbContextModelSnapshot.cs | 382 +++++++++++++++++ Models/City.cs | 29 -- Models/Country.cs | 2 - readme.md | 54 --- 6 files changed, 1043 insertions(+), 85 deletions(-) create mode 100644 Migrations/20221115170737_Initial.Designer.cs create mode 100644 Migrations/20221115170737_Initial.cs create mode 100644 Migrations/AppDbContextModelSnapshot.cs delete mode 100644 Models/City.cs diff --git a/Migrations/20221115170737_Initial.Designer.cs b/Migrations/20221115170737_Initial.Designer.cs new file mode 100644 index 0000000..c1fe056 --- /dev/null +++ b/Migrations/20221115170737_Initial.Designer.cs @@ -0,0 +1,385 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using NetTopologySuite.Geometries; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using labdb.Models; + +#nullable disable + +namespace labdb.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20221115170737_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "postgis"); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("labdb.Models.Country", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text") + .HasColumnName("code"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text") + .HasColumnName("english_name"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.HasKey("Id") + .HasName("pk_country"); + + b.HasIndex(new[] { "Name" }, "name") + .IsUnique() + .HasDatabaseName("ix_country_name"); + + b.HasIndex(new[] { "Name" }, "name_trgm") + .HasDatabaseName("ix_country_name1"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex(new[] { "Name" }, "name_trgm"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex(new[] { "Name" }, "name_trgm"), new[] { "gin_trgm_ops" }); + + b.ToTable("country", (string)null); + + b.HasData( + new + { + Id = new Guid("50de594a-9828-4c50-8ec0-3803cc359dc0"), + Code = "DE", + EnglishName = "Germany", + Name = "Deutschland" + }, + new + { + Id = new Guid("b7fb8044-148f-41e6-aedc-2d982cacc4fe"), + Code = "TEST", + EnglishName = "TEST COUNTRY", + Name = "TEST" + }); + }); + + modelBuilder.Entity("labdb.Models.Lab", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("AddressCity") + .HasColumnType("text") + .HasColumnName("address_city"); + + b.Property("AddressLine1") + .HasColumnType("text") + .HasColumnName("address_line1"); + + b.Property("AddressLine2") + .HasColumnType("text") + .HasColumnName("address_line2"); + + b.Property("AddressPostcode") + .HasColumnType("text") + .HasColumnName("address_postcode"); + + b.Property("BasicFee") + .HasColumnType("numeric") + .HasColumnName("basic_fee"); + + b.Property("CountryId") + .HasColumnType("uuid") + .HasColumnName("country_id"); + + b.Property("DrawFee") + .HasColumnType("numeric") + .HasColumnName("draw_fee"); + + b.Property("Email") + .HasColumnType("text") + .HasColumnName("email"); + + b.Property("Location") + .HasColumnType("geometry") + .HasColumnName("location"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("Phone") + .HasColumnType("text") + .HasColumnName("phone"); + + b.Property("RequiresAppointment") + .HasColumnType("boolean") + .HasColumnName("requires_appointment"); + + b.Property("SelfDraw") + .HasColumnType("boolean") + .HasColumnName("self_draw"); + + b.Property("Website") + .HasColumnType("text") + .HasColumnName("website"); + + b.HasKey("Id") + .HasName("pk_lab"); + + b.HasIndex("AddressPostcode") + .HasDatabaseName("ix_lab_address_postcode"); + + b.HasIndex("BasicFee") + .HasDatabaseName("ix_lab_basic_fee"); + + b.HasIndex("CountryId") + .HasDatabaseName("ix_lab_country_id"); + + b.HasIndex("DrawFee") + .HasDatabaseName("ix_lab_draw_fee"); + + b.HasIndex("RequiresAppointment") + .HasDatabaseName("ix_lab_requires_appointment"); + + b.HasIndex("SelfDraw") + .HasDatabaseName("ix_lab_self_draw"); + + b.HasIndex(new[] { "Name" }, "name") + .HasDatabaseName("ix_lab_name"); + + b.HasIndex(new[] { "Name" }, "name_trgm") + .HasDatabaseName("ix_lab_name"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex(new[] { "Name" }, "name_trgm"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex(new[] { "Name" }, "name_trgm"), new[] { "gin_trgm_ops" }); + + b.ToTable("lab", (string)null); + }); + + modelBuilder.Entity("labdb.Models.Test", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Abbreviation") + .HasColumnType("text") + .HasColumnName("abbreviation"); + + b.Property("Description") + .HasColumnType("text") + .HasColumnName("description"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("PubchemLink") + .HasColumnType("text") + .HasColumnName("pubchem_link"); + + b.HasKey("Id") + .HasName("pk_test"); + + b.HasIndex(new[] { "Abbreviation" }, "abbreviation") + .IsUnique() + .HasDatabaseName("ix_test_abbreviation"); + + b.HasIndex(new[] { "Abbreviation" }, "abbreviation_trgm") + .HasDatabaseName("ix_test_abbreviation1"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex(new[] { "Abbreviation" }, "abbreviation_trgm"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex(new[] { "Abbreviation" }, "abbreviation_trgm"), new[] { "gin_trgm_ops" }); + + b.HasIndex(new[] { "Name" }, "name") + .IsUnique() + .HasDatabaseName("ix_test_name"); + + b.HasIndex(new[] { "Name" }, "name_trgm") + .HasDatabaseName("ix_test_name1"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex(new[] { "Name" }, "name_trgm"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex(new[] { "Name" }, "name_trgm"), new[] { "gin_trgm_ops" }); + + b.ToTable("test", (string)null); + }); + + modelBuilder.Entity("labdb.Models.TestOffer", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("BloodVolume") + .HasColumnType("numeric") + .HasColumnName("blood_volume"); + + b.Property("LabId") + .HasColumnType("uuid") + .HasColumnName("lab_id"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("Price") + .HasColumnType("numeric") + .HasColumnName("price"); + + b.Property("ServiceDirectoryLink") + .HasColumnType("text") + .HasColumnName("service_directory_link"); + + b.Property("TestId") + .HasColumnType("uuid") + .HasColumnName("test_id"); + + b.Property("TestMethod") + .HasColumnType("text") + .HasColumnName("test_method"); + + b.HasKey("Id") + .HasName("pk_test_offer"); + + b.HasIndex("BloodVolume") + .HasDatabaseName("ix_test_offer_blood_volume"); + + b.HasIndex("LabId") + .HasDatabaseName("ix_test_offer_lab_id"); + + b.HasIndex("Price") + .HasDatabaseName("ix_test_offer_price"); + + b.HasIndex("TestId") + .HasDatabaseName("ix_test_offer_test_id"); + + b.HasIndex("TestMethod") + .HasDatabaseName("ix_test_offer_test_method"); + + b.ToTable("test_offer", (string)null); + }); + + modelBuilder.Entity("labdb.Models.TestSynonym", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("TestId") + .HasColumnType("uuid") + .HasColumnName("test_id"); + + b.HasKey("Id") + .HasName("pk_test_synonym"); + + b.HasIndex("TestId") + .HasDatabaseName("ix_test_synonym_test_id"); + + b.HasIndex(new[] { "Name" }, "name") + .IsUnique() + .HasDatabaseName("ix_test_synonym_name"); + + b.HasIndex(new[] { "Name" }, "name_trgm") + .HasDatabaseName("ix_test_synonym_name1"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex(new[] { "Name" }, "name_trgm"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex(new[] { "Name" }, "name_trgm"), new[] { "gin_trgm_ops" }); + + b.ToTable("test_synonym", (string)null); + }); + + modelBuilder.Entity("labdb.Models.Lab", b => + { + b.HasOne("labdb.Models.Country", "Country") + .WithMany("Labs") + .HasForeignKey("CountryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_lab_country_country_temp_id"); + + b.Navigation("Country"); + }); + + modelBuilder.Entity("labdb.Models.TestOffer", b => + { + b.HasOne("labdb.Models.Lab", "Lab") + .WithMany("TestOffers") + .HasForeignKey("LabId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_test_offer_lab_lab_temp_id"); + + b.HasOne("labdb.Models.Test", "Test") + .WithMany("TestOffers") + .HasForeignKey("TestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_test_offer_test_test_temp_id"); + + b.Navigation("Lab"); + + b.Navigation("Test"); + }); + + modelBuilder.Entity("labdb.Models.TestSynonym", b => + { + b.HasOne("labdb.Models.Test", "Test") + .WithMany("Synonyms") + .HasForeignKey("TestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_test_synonym_test_test_temp_id1"); + + b.Navigation("Test"); + }); + + modelBuilder.Entity("labdb.Models.Country", b => + { + b.Navigation("Labs"); + }); + + modelBuilder.Entity("labdb.Models.Lab", b => + { + b.Navigation("TestOffers"); + }); + + modelBuilder.Entity("labdb.Models.Test", b => + { + b.Navigation("Synonyms"); + + b.Navigation("TestOffers"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20221115170737_Initial.cs b/Migrations/20221115170737_Initial.cs new file mode 100644 index 0000000..7925343 --- /dev/null +++ b/Migrations/20221115170737_Initial.cs @@ -0,0 +1,276 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using NetTopologySuite.Geometries; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace labdb.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("Npgsql:PostgresExtension:postgis", ",,"); + + migrationBuilder.CreateTable( + name: "country", + columns: table => new + { + id = table.Column(type: "uuid", nullable: false), + name = table.Column(type: "text", nullable: false), + englishname = table.Column(name: "english_name", type: "text", nullable: false), + code = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_country", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "test", + columns: table => new + { + id = table.Column(type: "uuid", nullable: false), + name = table.Column(type: "text", nullable: false), + abbreviation = table.Column(type: "text", nullable: true), + description = table.Column(type: "text", nullable: true), + pubchemlink = table.Column(name: "pubchem_link", type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_test", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "lab", + columns: table => new + { + id = table.Column(type: "uuid", nullable: false), + name = table.Column(type: "text", nullable: false), + website = table.Column(type: "text", nullable: true), + phone = table.Column(type: "text", nullable: true), + email = table.Column(type: "text", nullable: true), + addressline1 = table.Column(name: "address_line1", type: "text", nullable: true), + addressline2 = table.Column(name: "address_line2", type: "text", nullable: true), + addresspostcode = table.Column(name: "address_postcode", type: "text", nullable: true), + addresscity = table.Column(name: "address_city", type: "text", nullable: true), + countryid = table.Column(name: "country_id", type: "uuid", nullable: false), + location = table.Column(type: "geometry", nullable: true), + requiresappointment = table.Column(name: "requires_appointment", type: "boolean", nullable: false), + selfdraw = table.Column(name: "self_draw", type: "boolean", nullable: false), + basicfee = table.Column(name: "basic_fee", type: "numeric", nullable: false), + drawfee = table.Column(name: "draw_fee", type: "numeric", nullable: false), + notes = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_lab", x => x.id); + table.ForeignKey( + name: "fk_lab_country_country_temp_id", + column: x => x.countryid, + principalTable: "country", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "test_synonym", + columns: table => new + { + id = table.Column(type: "uuid", nullable: false), + testid = table.Column(name: "test_id", type: "uuid", nullable: false), + name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_test_synonym", x => x.id); + table.ForeignKey( + name: "fk_test_synonym_test_test_temp_id1", + column: x => x.testid, + principalTable: "test", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "test_offer", + columns: table => new + { + id = table.Column(type: "uuid", nullable: false), + labid = table.Column(name: "lab_id", type: "uuid", nullable: false), + testid = table.Column(name: "test_id", type: "uuid", nullable: false), + price = table.Column(type: "numeric", nullable: false), + servicedirectorylink = table.Column(name: "service_directory_link", type: "text", nullable: true), + bloodvolume = table.Column(name: "blood_volume", type: "numeric", nullable: false), + testmethod = table.Column(name: "test_method", type: "text", nullable: true), + notes = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_test_offer", x => x.id); + table.ForeignKey( + name: "fk_test_offer_lab_lab_temp_id", + column: x => x.labid, + principalTable: "lab", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "fk_test_offer_test_test_temp_id", + column: x => x.testid, + principalTable: "test", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + table: "country", + columns: new[] { "id", "code", "english_name", "name" }, + values: new object[,] + { + { new Guid("50de594a-9828-4c50-8ec0-3803cc359dc0"), "DE", "Germany", "Deutschland" }, + { new Guid("b7fb8044-148f-41e6-aedc-2d982cacc4fe"), "TEST", "TEST COUNTRY", "TEST" } + }); + + migrationBuilder.CreateIndex( + name: "ix_country_name", + table: "country", + column: "name", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_country_name1", + table: "country", + column: "name") + .Annotation("Npgsql:IndexMethod", "gin") + .Annotation("Npgsql:IndexOperators", new[] { "gin_trgm_ops" }); + + migrationBuilder.CreateIndex( + name: "ix_lab_address_postcode", + table: "lab", + column: "address_postcode"); + + migrationBuilder.CreateIndex( + name: "ix_lab_basic_fee", + table: "lab", + column: "basic_fee"); + + migrationBuilder.CreateIndex( + name: "ix_lab_country_id", + table: "lab", + column: "country_id"); + + migrationBuilder.CreateIndex( + name: "ix_lab_draw_fee", + table: "lab", + column: "draw_fee"); + + migrationBuilder.CreateIndex( + name: "ix_lab_name", + table: "lab", + column: "name"); + + migrationBuilder.CreateIndex( + name: "ix_lab_requires_appointment", + table: "lab", + column: "requires_appointment"); + + migrationBuilder.CreateIndex( + name: "ix_lab_self_draw", + table: "lab", + column: "self_draw"); + + migrationBuilder.CreateIndex( + name: "ix_test_abbreviation", + table: "test", + column: "abbreviation", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_test_abbreviation1", + table: "test", + column: "abbreviation") + .Annotation("Npgsql:IndexMethod", "gin") + .Annotation("Npgsql:IndexOperators", new[] { "gin_trgm_ops" }); + + migrationBuilder.CreateIndex( + name: "ix_test_name", + table: "test", + column: "name", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_test_name1", + table: "test", + column: "name") + .Annotation("Npgsql:IndexMethod", "gin") + .Annotation("Npgsql:IndexOperators", new[] { "gin_trgm_ops" }); + + migrationBuilder.CreateIndex( + name: "ix_test_offer_blood_volume", + table: "test_offer", + column: "blood_volume"); + + migrationBuilder.CreateIndex( + name: "ix_test_offer_lab_id", + table: "test_offer", + column: "lab_id"); + + migrationBuilder.CreateIndex( + name: "ix_test_offer_price", + table: "test_offer", + column: "price"); + + migrationBuilder.CreateIndex( + name: "ix_test_offer_test_id", + table: "test_offer", + column: "test_id"); + + migrationBuilder.CreateIndex( + name: "ix_test_offer_test_method", + table: "test_offer", + column: "test_method"); + + migrationBuilder.CreateIndex( + name: "ix_test_synonym_name", + table: "test_synonym", + column: "name", + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_test_synonym_name1", + table: "test_synonym", + column: "name") + .Annotation("Npgsql:IndexMethod", "gin") + .Annotation("Npgsql:IndexOperators", new[] { "gin_trgm_ops" }); + + migrationBuilder.CreateIndex( + name: "ix_test_synonym_test_id", + table: "test_synonym", + column: "test_id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "test_offer"); + + migrationBuilder.DropTable( + name: "test_synonym"); + + migrationBuilder.DropTable( + name: "lab"); + + migrationBuilder.DropTable( + name: "test"); + + migrationBuilder.DropTable( + name: "country"); + } + } +} diff --git a/Migrations/AppDbContextModelSnapshot.cs b/Migrations/AppDbContextModelSnapshot.cs new file mode 100644 index 0000000..d105a66 --- /dev/null +++ b/Migrations/AppDbContextModelSnapshot.cs @@ -0,0 +1,382 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using NetTopologySuite.Geometries; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using labdb.Models; + +#nullable disable + +namespace labdb.Migrations +{ + [DbContext(typeof(AppDbContext))] + partial class AppDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "postgis"); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("labdb.Models.Country", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text") + .HasColumnName("code"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text") + .HasColumnName("english_name"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.HasKey("Id") + .HasName("pk_country"); + + b.HasIndex(new[] { "Name" }, "name") + .IsUnique() + .HasDatabaseName("ix_country_name"); + + b.HasIndex(new[] { "Name" }, "name_trgm") + .HasDatabaseName("ix_country_name1"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex(new[] { "Name" }, "name_trgm"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex(new[] { "Name" }, "name_trgm"), new[] { "gin_trgm_ops" }); + + b.ToTable("country", (string)null); + + b.HasData( + new + { + Id = new Guid("50de594a-9828-4c50-8ec0-3803cc359dc0"), + Code = "DE", + EnglishName = "Germany", + Name = "Deutschland" + }, + new + { + Id = new Guid("b7fb8044-148f-41e6-aedc-2d982cacc4fe"), + Code = "TEST", + EnglishName = "TEST COUNTRY", + Name = "TEST" + }); + }); + + modelBuilder.Entity("labdb.Models.Lab", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("AddressCity") + .HasColumnType("text") + .HasColumnName("address_city"); + + b.Property("AddressLine1") + .HasColumnType("text") + .HasColumnName("address_line1"); + + b.Property("AddressLine2") + .HasColumnType("text") + .HasColumnName("address_line2"); + + b.Property("AddressPostcode") + .HasColumnType("text") + .HasColumnName("address_postcode"); + + b.Property("BasicFee") + .HasColumnType("numeric") + .HasColumnName("basic_fee"); + + b.Property("CountryId") + .HasColumnType("uuid") + .HasColumnName("country_id"); + + b.Property("DrawFee") + .HasColumnType("numeric") + .HasColumnName("draw_fee"); + + b.Property("Email") + .HasColumnType("text") + .HasColumnName("email"); + + b.Property("Location") + .HasColumnType("geometry") + .HasColumnName("location"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("Phone") + .HasColumnType("text") + .HasColumnName("phone"); + + b.Property("RequiresAppointment") + .HasColumnType("boolean") + .HasColumnName("requires_appointment"); + + b.Property("SelfDraw") + .HasColumnType("boolean") + .HasColumnName("self_draw"); + + b.Property("Website") + .HasColumnType("text") + .HasColumnName("website"); + + b.HasKey("Id") + .HasName("pk_lab"); + + b.HasIndex("AddressPostcode") + .HasDatabaseName("ix_lab_address_postcode"); + + b.HasIndex("BasicFee") + .HasDatabaseName("ix_lab_basic_fee"); + + b.HasIndex("CountryId") + .HasDatabaseName("ix_lab_country_id"); + + b.HasIndex("DrawFee") + .HasDatabaseName("ix_lab_draw_fee"); + + b.HasIndex("RequiresAppointment") + .HasDatabaseName("ix_lab_requires_appointment"); + + b.HasIndex("SelfDraw") + .HasDatabaseName("ix_lab_self_draw"); + + b.HasIndex(new[] { "Name" }, "name") + .HasDatabaseName("ix_lab_name"); + + b.HasIndex(new[] { "Name" }, "name_trgm") + .HasDatabaseName("ix_lab_name"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex(new[] { "Name" }, "name_trgm"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex(new[] { "Name" }, "name_trgm"), new[] { "gin_trgm_ops" }); + + b.ToTable("lab", (string)null); + }); + + modelBuilder.Entity("labdb.Models.Test", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Abbreviation") + .HasColumnType("text") + .HasColumnName("abbreviation"); + + b.Property("Description") + .HasColumnType("text") + .HasColumnName("description"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("PubchemLink") + .HasColumnType("text") + .HasColumnName("pubchem_link"); + + b.HasKey("Id") + .HasName("pk_test"); + + b.HasIndex(new[] { "Abbreviation" }, "abbreviation") + .IsUnique() + .HasDatabaseName("ix_test_abbreviation"); + + b.HasIndex(new[] { "Abbreviation" }, "abbreviation_trgm") + .HasDatabaseName("ix_test_abbreviation1"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex(new[] { "Abbreviation" }, "abbreviation_trgm"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex(new[] { "Abbreviation" }, "abbreviation_trgm"), new[] { "gin_trgm_ops" }); + + b.HasIndex(new[] { "Name" }, "name") + .IsUnique() + .HasDatabaseName("ix_test_name"); + + b.HasIndex(new[] { "Name" }, "name_trgm") + .HasDatabaseName("ix_test_name1"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex(new[] { "Name" }, "name_trgm"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex(new[] { "Name" }, "name_trgm"), new[] { "gin_trgm_ops" }); + + b.ToTable("test", (string)null); + }); + + modelBuilder.Entity("labdb.Models.TestOffer", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("BloodVolume") + .HasColumnType("numeric") + .HasColumnName("blood_volume"); + + b.Property("LabId") + .HasColumnType("uuid") + .HasColumnName("lab_id"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("Price") + .HasColumnType("numeric") + .HasColumnName("price"); + + b.Property("ServiceDirectoryLink") + .HasColumnType("text") + .HasColumnName("service_directory_link"); + + b.Property("TestId") + .HasColumnType("uuid") + .HasColumnName("test_id"); + + b.Property("TestMethod") + .HasColumnType("text") + .HasColumnName("test_method"); + + b.HasKey("Id") + .HasName("pk_test_offer"); + + b.HasIndex("BloodVolume") + .HasDatabaseName("ix_test_offer_blood_volume"); + + b.HasIndex("LabId") + .HasDatabaseName("ix_test_offer_lab_id"); + + b.HasIndex("Price") + .HasDatabaseName("ix_test_offer_price"); + + b.HasIndex("TestId") + .HasDatabaseName("ix_test_offer_test_id"); + + b.HasIndex("TestMethod") + .HasDatabaseName("ix_test_offer_test_method"); + + b.ToTable("test_offer", (string)null); + }); + + modelBuilder.Entity("labdb.Models.TestSynonym", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("TestId") + .HasColumnType("uuid") + .HasColumnName("test_id"); + + b.HasKey("Id") + .HasName("pk_test_synonym"); + + b.HasIndex("TestId") + .HasDatabaseName("ix_test_synonym_test_id"); + + b.HasIndex(new[] { "Name" }, "name") + .IsUnique() + .HasDatabaseName("ix_test_synonym_name"); + + b.HasIndex(new[] { "Name" }, "name_trgm") + .HasDatabaseName("ix_test_synonym_name1"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex(new[] { "Name" }, "name_trgm"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex(new[] { "Name" }, "name_trgm"), new[] { "gin_trgm_ops" }); + + b.ToTable("test_synonym", (string)null); + }); + + modelBuilder.Entity("labdb.Models.Lab", b => + { + b.HasOne("labdb.Models.Country", "Country") + .WithMany("Labs") + .HasForeignKey("CountryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_lab_country_country_temp_id"); + + b.Navigation("Country"); + }); + + modelBuilder.Entity("labdb.Models.TestOffer", b => + { + b.HasOne("labdb.Models.Lab", "Lab") + .WithMany("TestOffers") + .HasForeignKey("LabId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_test_offer_lab_lab_temp_id"); + + b.HasOne("labdb.Models.Test", "Test") + .WithMany("TestOffers") + .HasForeignKey("TestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_test_offer_test_test_temp_id"); + + b.Navigation("Lab"); + + b.Navigation("Test"); + }); + + modelBuilder.Entity("labdb.Models.TestSynonym", b => + { + b.HasOne("labdb.Models.Test", "Test") + .WithMany("Synonyms") + .HasForeignKey("TestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_test_synonym_test_test_temp_id1"); + + b.Navigation("Test"); + }); + + modelBuilder.Entity("labdb.Models.Country", b => + { + b.Navigation("Labs"); + }); + + modelBuilder.Entity("labdb.Models.Lab", b => + { + b.Navigation("TestOffers"); + }); + + modelBuilder.Entity("labdb.Models.Test", b => + { + b.Navigation("Synonyms"); + + b.Navigation("TestOffers"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Models/City.cs b/Models/City.cs deleted file mode 100644 index d9636e8..0000000 --- a/Models/City.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using NetTopologySuite.Geometries; - -namespace labdb.Models; - -public record CityId : EntityIdBase; - -public class City : EntityBase -{ - public string Name { get; set; } = null!; - public string? EnglishName { get; set; } - public CountryId CountryId { get; set; } = null!; - public Country Country { get; set; } = null!; - public Point Location { get; set; } = null!; -} - -public class CityConfiguration : EntityBaseConfiguration -{ - public override void Configure(EntityTypeBuilder builder) - { - base.Configure(builder); - - builder.HasIndex(x => x.Name, "name").IsUnique(); - builder.HasIndex(x => x.Name, "name_trgm").HasMethod("gin").HasOperators("gin_trgm_ops"); - builder.HasIndex(x => x.EnglishName, "english_name").IsUnique(); - builder.HasIndex(x => x.EnglishName, "english_name_trgm").HasMethod("gin").HasOperators("gin_trgm_ops"); - } -} \ No newline at end of file diff --git a/Models/Country.cs b/Models/Country.cs index abcb227..230e56d 100644 --- a/Models/Country.cs +++ b/Models/Country.cs @@ -13,8 +13,6 @@ public class Country : EntityBase public string Code { get; init; } = null!; - public List Cities { get; set; } = new(); - public List Labs { get; set; } = new(); } diff --git a/readme.md b/readme.md index ce3aa8d..e69de29 100644 --- a/readme.md +++ b/readme.md @@ -1,54 +0,0 @@ -# datenbankschemaLocaition - -labs: - --[x] name `name` #string search index --[x] website `website` #string --[x] phone number `phone` #string --[x] email address `email` #string --[x] address line 1 `address_line1` #string --[x] address line 2 `address_line2` #string --[x] postcode `address_postcode` #string index --[x] city `address_city` #string index --[x] country (ref id) `country_id` #number foreign key --[x] location coordinates `location` #geography --[x] requires appointment `requires_appointment` #boolean index --[x] allows self drawing blood `self_draw` #boolean index --[x] basic fee `basic_fee` #number index --[x] blood drawing fee `draw_fee` #number index --[x] notes `notes` #text --[ ] last updated `last_updated` #datetime or something - -tests: - --[x] name `name` #string search index --[x] abbreviation `abbreviation` #string search index --[x] description `description` #text --[x] pubchem link `pubchem_link` #string - -tests_synonyms: - --[ ] test (id ref) `test_id` #number foreign key --[ ] synonym name `synonym` #string search index - -labs_tests: - --[x] labor (id ref) `lab_id` #number foreign key --[x] test (id ref) `test_id` #number foreign key --[x] price `price` #number index --[x] leistungsverzeichnis link (if available) `service_directory_link` #string --[x] required blood volume `blood_volume` #number --[x] test method? `test_method` #string --[x] notes `notes` #text --[ ] last updated `last_updated` #datetime? - -countries: - --[x] name `name` #string index - -cities (for search): - --[x] name `name` #string index --[x] english name if different from german `name_english` #string index --[x] country (ref id) `country_id` #number foreign key --[x] location `location` #geography \ No newline at end of file