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.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"); } } }