[a8ccc2c] | 1 | using System;
|
---|
| 2 | using Microsoft.EntityFrameworkCore.Migrations;
|
---|
| 3 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
---|
| 4 |
|
---|
| 5 | namespace FarmatikoData.Migrations
|
---|
| 6 | {
|
---|
| 7 | public partial class Initialmigration : Migration
|
---|
| 8 | {
|
---|
| 9 | protected override void Up(MigrationBuilder migrationBuilder)
|
---|
| 10 | {
|
---|
| 11 | migrationBuilder.CreateTable(
|
---|
| 12 | name: "HealthFacilities",
|
---|
| 13 | columns: table => new
|
---|
| 14 | {
|
---|
| 15 | Id = table.Column<int>(nullable: false)
|
---|
| 16 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
---|
[d2e69be] | 17 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
| 18 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[a8ccc2c] | 19 | Name = table.Column<string>(nullable: false),
|
---|
| 20 | Municipality = table.Column<string>(nullable: false),
|
---|
| 21 | Address = table.Column<string>(nullable: false),
|
---|
| 22 | Type = table.Column<string>(nullable: false),
|
---|
| 23 | Email = table.Column<string>(nullable: true),
|
---|
| 24 | Phone = table.Column<string>(nullable: true)
|
---|
| 25 | },
|
---|
[e42f61a] | 26 | constraints: table =>
|
---|
[a8ccc2c] | 27 | {
|
---|
| 28 | table.PrimaryKey("PK_HealthFacilities", x => x.Id);
|
---|
| 29 | });
|
---|
| 30 |
|
---|
| 31 | migrationBuilder.CreateTable(
|
---|
| 32 | name: "Pandemics",
|
---|
| 33 | columns: table => new
|
---|
| 34 | {
|
---|
| 35 | Id = table.Column<int>(nullable: false)
|
---|
| 36 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
---|
[d2e69be] | 37 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
| 38 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[a8ccc2c] | 39 | Name = table.Column<string>(nullable: true),
|
---|
| 40 | TotalMK = table.Column<int>(nullable: false),
|
---|
| 41 | ActiveMK = table.Column<int>(nullable: false),
|
---|
| 42 | DeathsMK = table.Column<int>(nullable: false),
|
---|
| 43 | NewMK = table.Column<int>(nullable: false),
|
---|
| 44 | TotalGlobal = table.Column<int>(nullable: false),
|
---|
| 45 | DeathsGlobal = table.Column<int>(nullable: false),
|
---|
| 46 | ActiveGlobal = table.Column<int>(nullable: false)
|
---|
| 47 | },
|
---|
| 48 | constraints: table =>
|
---|
| 49 | {
|
---|
| 50 | table.PrimaryKey("PK_Pandemics", x => x.Id);
|
---|
| 51 | });
|
---|
| 52 |
|
---|
| 53 | migrationBuilder.CreateTable(
|
---|
| 54 | name: "HealthcareWorkers",
|
---|
| 55 | columns: table => new
|
---|
| 56 | {
|
---|
| 57 | Id = table.Column<int>(nullable: false)
|
---|
| 58 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
---|
[d2e69be] | 59 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
| 60 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[a8ccc2c] | 61 | Name = table.Column<string>(nullable: false),
|
---|
| 62 | Branch = table.Column<string>(nullable: false),
|
---|
| 63 | FacilityId = table.Column<int>(nullable: false),
|
---|
| 64 | Title = table.Column<string>(nullable: true)
|
---|
| 65 | },
|
---|
| 66 | constraints: table =>
|
---|
| 67 | {
|
---|
| 68 | table.PrimaryKey("PK_HealthcareWorkers", x => x.Id);
|
---|
| 69 | table.ForeignKey(
|
---|
| 70 | name: "FK_HealthcareWorkers_HealthFacilities_FacilityId",
|
---|
| 71 | column: x => x.FacilityId,
|
---|
| 72 | principalTable: "HealthFacilities",
|
---|
| 73 | principalColumn: "Id",
|
---|
| 74 | onDelete: ReferentialAction.Cascade);
|
---|
| 75 | });
|
---|
| 76 |
|
---|
| 77 | migrationBuilder.CreateTable(
|
---|
| 78 | name: "Medicines",
|
---|
| 79 | columns: table => new
|
---|
| 80 | {
|
---|
| 81 | Id = table.Column<int>(nullable: false)
|
---|
| 82 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
---|
[d2e69be] | 83 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
| 84 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[a8ccc2c] | 85 | Name = table.Column<string>(nullable: true),
|
---|
| 86 | Strength = table.Column<string>(nullable: true),
|
---|
| 87 | Form = table.Column<string>(nullable: true),
|
---|
| 88 | WayOfIssuing = table.Column<string>(nullable: true),
|
---|
| 89 | Manufacturer = table.Column<string>(nullable: true),
|
---|
| 90 | Price = table.Column<float>(nullable: false),
|
---|
| 91 | Packaging = table.Column<string>(nullable: true),
|
---|
| 92 | MedicineListId = table.Column<int>(nullable: true)
|
---|
| 93 | },
|
---|
| 94 | constraints: table =>
|
---|
| 95 | {
|
---|
| 96 | table.PrimaryKey("PK_Medicines", x => x.Id);
|
---|
| 97 | });
|
---|
| 98 |
|
---|
| 99 | migrationBuilder.CreateTable(
|
---|
| 100 | name: "PharmacyHeads",
|
---|
| 101 | columns: table => new
|
---|
| 102 | {
|
---|
| 103 | Id = table.Column<int>(nullable: false)
|
---|
| 104 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
---|
[d2e69be] | 105 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
| 106 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[a8ccc2c] | 107 | PharmacyMedicinesId = table.Column<int>(nullable: true),
|
---|
| 108 | PharmacyId = table.Column<int>(nullable: true),
|
---|
| 109 | Email = table.Column<string>(nullable: true),
|
---|
| 110 | Name = table.Column<string>(nullable: true),
|
---|
| 111 | Password = table.Column<string>(nullable: true)
|
---|
| 112 | },
|
---|
| 113 | constraints: table =>
|
---|
| 114 | {
|
---|
| 115 | table.PrimaryKey("PK_PharmacyHeads", x => x.Id);
|
---|
| 116 | });
|
---|
| 117 |
|
---|
| 118 | migrationBuilder.CreateTable(
|
---|
| 119 | name: "MedicineLists",
|
---|
| 120 | columns: table => new
|
---|
| 121 | {
|
---|
| 122 | Id = table.Column<int>(nullable: false)
|
---|
| 123 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
---|
[d2e69be] | 124 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
| 125 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[a8ccc2c] | 126 | MedicinesId = table.Column<int>(nullable: true),
|
---|
| 127 | HasMedicine = table.Column<bool>(nullable: false),
|
---|
| 128 | PharmacyHeadId = table.Column<int>(nullable: true)
|
---|
| 129 | },
|
---|
| 130 | constraints: table =>
|
---|
| 131 | {
|
---|
| 132 | table.PrimaryKey("PK_MedicineLists", x => x.Id);
|
---|
| 133 | table.ForeignKey(
|
---|
| 134 | name: "FK_MedicineLists_Medicines_MedicinesId",
|
---|
| 135 | column: x => x.MedicinesId,
|
---|
| 136 | principalTable: "Medicines",
|
---|
| 137 | principalColumn: "Id",
|
---|
| 138 | onDelete: ReferentialAction.Restrict);
|
---|
| 139 | table.ForeignKey(
|
---|
| 140 | name: "FK_MedicineLists_PharmacyHeads_PharmacyHeadId",
|
---|
| 141 | column: x => x.PharmacyHeadId,
|
---|
| 142 | principalTable: "PharmacyHeads",
|
---|
| 143 | principalColumn: "Id",
|
---|
| 144 | onDelete: ReferentialAction.Restrict);
|
---|
| 145 | });
|
---|
| 146 |
|
---|
| 147 | migrationBuilder.CreateTable(
|
---|
| 148 | name: "Pharmacies",
|
---|
| 149 | columns: table => new
|
---|
| 150 | {
|
---|
| 151 | Id = table.Column<int>(nullable: false)
|
---|
| 152 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
---|
[d2e69be] | 153 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
| 154 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[a8ccc2c] | 155 | Name = table.Column<string>(nullable: true),
|
---|
| 156 | Location = table.Column<string>(nullable: true),
|
---|
| 157 | Address = table.Column<string>(nullable: true),
|
---|
| 158 | WorkAllTime = table.Column<bool>(nullable: false),
|
---|
| 159 | PharmacyHeadId = table.Column<int>(nullable: true)
|
---|
| 160 | },
|
---|
| 161 | constraints: table =>
|
---|
| 162 | {
|
---|
| 163 | table.PrimaryKey("PK_Pharmacies", x => x.Id);
|
---|
| 164 | table.ForeignKey(
|
---|
| 165 | name: "FK_Pharmacies_PharmacyHeads_PharmacyHeadId",
|
---|
| 166 | column: x => x.PharmacyHeadId,
|
---|
| 167 | principalTable: "PharmacyHeads",
|
---|
| 168 | principalColumn: "Id",
|
---|
| 169 | onDelete: ReferentialAction.Restrict);
|
---|
| 170 | });
|
---|
| 171 |
|
---|
| 172 | migrationBuilder.CreateIndex(
|
---|
| 173 | name: "IX_HealthcareWorkers_FacilityId",
|
---|
| 174 | table: "HealthcareWorkers",
|
---|
| 175 | column: "FacilityId");
|
---|
| 176 |
|
---|
| 177 | migrationBuilder.CreateIndex(
|
---|
| 178 | name: "IX_MedicineLists_MedicinesId",
|
---|
| 179 | table: "MedicineLists",
|
---|
| 180 | column: "MedicinesId");
|
---|
| 181 |
|
---|
| 182 | migrationBuilder.CreateIndex(
|
---|
| 183 | name: "IX_MedicineLists_PharmacyHeadId",
|
---|
| 184 | table: "MedicineLists",
|
---|
| 185 | column: "PharmacyHeadId");
|
---|
| 186 |
|
---|
| 187 | migrationBuilder.CreateIndex(
|
---|
| 188 | name: "IX_Medicines_MedicineListId",
|
---|
| 189 | table: "Medicines",
|
---|
| 190 | column: "MedicineListId");
|
---|
| 191 |
|
---|
| 192 | migrationBuilder.CreateIndex(
|
---|
| 193 | name: "IX_Pharmacies_PharmacyHeadId",
|
---|
| 194 | table: "Pharmacies",
|
---|
| 195 | column: "PharmacyHeadId");
|
---|
| 196 |
|
---|
| 197 | migrationBuilder.CreateIndex(
|
---|
| 198 | name: "IX_PharmacyHeads_PharmacyId",
|
---|
| 199 | table: "PharmacyHeads",
|
---|
| 200 | column: "PharmacyId");
|
---|
| 201 |
|
---|
| 202 | migrationBuilder.CreateIndex(
|
---|
| 203 | name: "IX_PharmacyHeads_PharmacyMedicinesId",
|
---|
| 204 | table: "PharmacyHeads",
|
---|
| 205 | column: "PharmacyMedicinesId");
|
---|
| 206 |
|
---|
| 207 | migrationBuilder.AddForeignKey(
|
---|
| 208 | name: "FK_Medicines_MedicineLists_MedicineListId",
|
---|
| 209 | table: "Medicines",
|
---|
| 210 | column: "MedicineListId",
|
---|
| 211 | principalTable: "MedicineLists",
|
---|
| 212 | principalColumn: "Id",
|
---|
| 213 | onDelete: ReferentialAction.Restrict);
|
---|
| 214 |
|
---|
| 215 | migrationBuilder.AddForeignKey(
|
---|
| 216 | name: "FK_PharmacyHeads_MedicineLists_PharmacyMedicinesId",
|
---|
| 217 | table: "PharmacyHeads",
|
---|
| 218 | column: "PharmacyMedicinesId",
|
---|
| 219 | principalTable: "MedicineLists",
|
---|
| 220 | principalColumn: "Id",
|
---|
| 221 | onDelete: ReferentialAction.Restrict);
|
---|
| 222 |
|
---|
| 223 | migrationBuilder.AddForeignKey(
|
---|
| 224 | name: "FK_PharmacyHeads_Pharmacies_PharmacyId",
|
---|
| 225 | table: "PharmacyHeads",
|
---|
| 226 | column: "PharmacyId",
|
---|
| 227 | principalTable: "Pharmacies",
|
---|
| 228 | principalColumn: "Id",
|
---|
| 229 | onDelete: ReferentialAction.Restrict);
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | protected override void Down(MigrationBuilder migrationBuilder)
|
---|
| 233 | {
|
---|
| 234 | migrationBuilder.DropForeignKey(
|
---|
| 235 | name: "FK_MedicineLists_Medicines_MedicinesId",
|
---|
| 236 | table: "MedicineLists");
|
---|
| 237 |
|
---|
| 238 | migrationBuilder.DropForeignKey(
|
---|
| 239 | name: "FK_MedicineLists_PharmacyHeads_PharmacyHeadId",
|
---|
| 240 | table: "MedicineLists");
|
---|
| 241 |
|
---|
| 242 | migrationBuilder.DropForeignKey(
|
---|
| 243 | name: "FK_Pharmacies_PharmacyHeads_PharmacyHeadId",
|
---|
| 244 | table: "Pharmacies");
|
---|
| 245 |
|
---|
| 246 | migrationBuilder.DropTable(
|
---|
| 247 | name: "HealthcareWorkers");
|
---|
| 248 |
|
---|
| 249 | migrationBuilder.DropTable(
|
---|
| 250 | name: "Pandemics");
|
---|
| 251 |
|
---|
| 252 | migrationBuilder.DropTable(
|
---|
| 253 | name: "HealthFacilities");
|
---|
| 254 |
|
---|
| 255 | migrationBuilder.DropTable(
|
---|
| 256 | name: "Medicines");
|
---|
| 257 |
|
---|
| 258 | migrationBuilder.DropTable(
|
---|
| 259 | name: "PharmacyHeads");
|
---|
| 260 |
|
---|
| 261 | migrationBuilder.DropTable(
|
---|
| 262 | name: "Pharmacies");
|
---|
| 263 |
|
---|
| 264 | migrationBuilder.DropTable(
|
---|
| 265 | name: "MedicineLists");
|
---|
| 266 | }
|
---|
| 267 | }
|
---|
| 268 | }
|
---|