274 lines
11 KiB
C#
274 lines
11 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
using NetTopologySuite.Geometries;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
|||
|
|
|||
|
namespace labdb.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class Initial : 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),
|
|||
|
englishname = table.Column<string>(name: "english_name", type: "text", nullable: false),
|
|||
|
code = 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: "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: "geometry", 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_temp_id",
|
|||
|
column: x => x.countryid,
|
|||
|
principalTable: "country",
|
|||
|
principalColumn: "id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "test_synonym",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
|||
|
testid = table.Column<Guid>(name: "test_id", type: "uuid", nullable: false),
|
|||
|
name = table.Column<string>(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<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_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");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
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");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|