281 lines
11 KiB
C#
281 lines
11 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using NetTopologySuite.Geometries;
|
|
|
|
#nullable disable
|
|
|
|
namespace labdb.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class ModelsInitial : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "country",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
name = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_country", x => x.id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "test",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
name = table.Column<string>(type: "text", nullable: false),
|
|
abbreviation = table.Column<string>(type: "text", nullable: true),
|
|
description = table.Column<string>(type: "text", nullable: true),
|
|
pubchemlink = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
|
|
name = table.Column<string>(type: "text", nullable: false),
|
|
englishname = table.Column<string>(name: "english_name", type: "text", nullable: true),
|
|
countryid = table.Column<Guid>(name: "country_id", type: "uuid", nullable: false),
|
|
location = table.Column<Point>(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<Guid>(type: "uuid", nullable: false),
|
|
name = table.Column<string>(type: "text", nullable: false),
|
|
website = table.Column<string>(type: "text", nullable: true),
|
|
phone = table.Column<string>(type: "text", nullable: true),
|
|
email = table.Column<string>(type: "text", nullable: true),
|
|
addressline1 = table.Column<string>(name: "address_line1", type: "text", nullable: true),
|
|
addressline2 = table.Column<string>(name: "address_line2", type: "text", nullable: true),
|
|
addresspostcode = table.Column<string>(name: "address_postcode", type: "text", nullable: true),
|
|
addresscity = table.Column<string>(name: "address_city", type: "text", nullable: true),
|
|
countryid = table.Column<Guid>(name: "country_id", type: "uuid", nullable: false),
|
|
location = table.Column<Point>(type: "geography(POINT,4326)", nullable: true),
|
|
requiresappointment = table.Column<bool>(name: "requires_appointment", type: "boolean", nullable: false),
|
|
selfdraw = table.Column<bool>(name: "self_draw", type: "boolean", nullable: false),
|
|
basicfee = table.Column<decimal>(name: "basic_fee", type: "numeric", nullable: false),
|
|
drawfee = table.Column<decimal>(name: "draw_fee", type: "numeric", nullable: false),
|
|
notes = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
|
|
labid = table.Column<Guid>(name: "lab_id", type: "uuid", nullable: false),
|
|
testid = table.Column<Guid>(name: "test_id", type: "uuid", nullable: false),
|
|
price = table.Column<decimal>(type: "numeric", nullable: false),
|
|
servicedirectorylink = table.Column<string>(name: "service_directory_link", type: "text", nullable: true),
|
|
bloodvolume = table.Column<decimal>(name: "blood_volume", type: "numeric", nullable: false),
|
|
testmethod = table.Column<string>(name: "test_method", type: "text", nullable: true),
|
|
notes = table.Column<string>(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" });
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
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");
|
|
}
|
|
}
|
|
}
|