using System; using Microsoft.EntityFrameworkCore.Migrations; using NetTopologySuite.Geometries; #nullable disable namespace labdb.Migrations { /// public partial class ModelsInitial : 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) }, 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: "city", 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: true), countryid = table.Column(name: "country_id", type: "uuid", nullable: false), location = table.Column(type: "geography(POINT,4326)", nullable: false) }, constraints: table => { table.PrimaryKey("pk_city", x => x.id); table.ForeignKey( name: "fk_city_country_country_temp_id", column: x => x.countryid, principalTable: "country", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); 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: "geography(POINT,4326)", 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_id1", column: x => x.countryid, principalTable: "country", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "lab_test", 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_lab_test", x => x.id); table.ForeignKey( name: "fk_lab_test_lab_lab_id1", column: x => x.labid, principalTable: "lab", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_lab_test_test_test_temp_id", column: x => x.testid, principalTable: "test", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "ix_city_country_id", table: "city", column: "country_id"); migrationBuilder.CreateIndex( name: "ix_city_english_name", table: "city", column: "english_name", unique: true); migrationBuilder.CreateIndex( name: "ix_city_english_name1", table: "city", column: "english_name") .Annotation("Npgsql:IndexMethod", "gin") .Annotation("Npgsql:IndexOperators", new[] { "gin_trgm_ops" }); migrationBuilder.CreateIndex( name: "ix_city_name", table: "city", column: "name", unique: true); migrationBuilder.CreateIndex( name: "ix_city_name1", table: "city", column: "name") .Annotation("Npgsql:IndexMethod", "gin") .Annotation("Npgsql:IndexOperators", new[] { "gin_trgm_ops" }); 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_city", table: "lab", column: "address_city"); 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_lab_test_blood_volume", table: "lab_test", column: "blood_volume"); migrationBuilder.CreateIndex( name: "ix_lab_test_lab_id", table: "lab_test", column: "lab_id"); migrationBuilder.CreateIndex( name: "ix_lab_test_price", table: "lab_test", column: "price"); migrationBuilder.CreateIndex( name: "ix_lab_test_test_id", table: "lab_test", column: "test_id"); migrationBuilder.CreateIndex( name: "ix_lab_test_test_method", table: "lab_test", column: "test_method"); 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" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "city"); migrationBuilder.DropTable( name: "lab_test"); migrationBuilder.DropTable( name: "lab"); migrationBuilder.DropTable( name: "test"); migrationBuilder.DropTable( name: "country"); } } }