[a8ccc2c] | 1 | using System;
|
---|
| 2 | using Microsoft.EntityFrameworkCore.Migrations;
|
---|
| 3 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
---|
| 4 |
|
---|
| 5 | namespace FarmatikoData.Migrations
|
---|
| 6 | {
|
---|
[d23bf72] | 7 | public partial class InitialMigration : Migration
|
---|
[a8ccc2c] | 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)
|
---|
[8e74e2f] | 16 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
| 17 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql:"now()"),
|
---|
[d2e69be] | 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 | },
|
---|
[d23bf72] | 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)
|
---|
[8e74e2f] | 36 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
[1db5673] | 37 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
[d2e69be] | 38 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[d23bf72] | 39 | Name = table.Column<string>(nullable: false),
|
---|
[a8ccc2c] | 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),
|
---|
[d23bf72] | 44 | TotalGlobal = table.Column<long>(nullable: false),
|
---|
| 45 | DeathsGlobal = table.Column<long>(nullable: false),
|
---|
| 46 | ActiveGlobal = table.Column<long>(nullable: false)
|
---|
[a8ccc2c] | 47 | },
|
---|
| 48 | constraints: table =>
|
---|
| 49 | {
|
---|
| 50 | table.PrimaryKey("PK_Pandemics", x => x.Id);
|
---|
| 51 | });
|
---|
| 52 |
|
---|
| 53 | migrationBuilder.CreateTable(
|
---|
[d23bf72] | 54 | name: "PharmacyHeads",
|
---|
[a8ccc2c] | 55 | columns: table => new
|
---|
| 56 | {
|
---|
| 57 | Id = table.Column<int>(nullable: false)
|
---|
[8e74e2f] | 58 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
[1db5673] | 59 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
[d2e69be] | 60 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[d23bf72] | 61 | Email = table.Column<string>(nullable: false),
|
---|
[a8ccc2c] | 62 | Name = table.Column<string>(nullable: false),
|
---|
[d23bf72] | 63 | Password = table.Column<string>(nullable: false)
|
---|
[a8ccc2c] | 64 | },
|
---|
| 65 | constraints: table =>
|
---|
| 66 | {
|
---|
[d23bf72] | 67 | table.PrimaryKey("PK_PharmacyHeads", x => x.Id);
|
---|
[a8ccc2c] | 68 | });
|
---|
| 69 |
|
---|
| 70 | migrationBuilder.CreateTable(
|
---|
[d23bf72] | 71 | name: "Users",
|
---|
[a8ccc2c] | 72 | columns: table => new
|
---|
| 73 | {
|
---|
| 74 | Id = table.Column<int>(nullable: false)
|
---|
[8e74e2f] | 75 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
[1db5673] | 76 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
[d2e69be] | 77 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[1db5673] | 78 | Name = table.Column<string>(nullable: false),
|
---|
| 79 | Email = table.Column<string>(nullable: false),
|
---|
| 80 | Password = table.Column<string>(nullable: false),
|
---|
[d23bf72] | 81 | UserRole = table.Column<int>(nullable: false)
|
---|
[a8ccc2c] | 82 | },
|
---|
| 83 | constraints: table =>
|
---|
| 84 | {
|
---|
[d23bf72] | 85 | table.PrimaryKey("PK_Users", x => x.Id);
|
---|
[a8ccc2c] | 86 | });
|
---|
| 87 |
|
---|
| 88 | migrationBuilder.CreateTable(
|
---|
[d23bf72] | 89 | name: "HealthcareWorkers",
|
---|
[a8ccc2c] | 90 | columns: table => new
|
---|
| 91 | {
|
---|
| 92 | Id = table.Column<int>(nullable: false)
|
---|
[8e74e2f] | 93 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
[1db5673] | 94 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
[d2e69be] | 95 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[d23bf72] | 96 | Name = table.Column<string>(nullable: false),
|
---|
| 97 | Branch = table.Column<string>(nullable: false),
|
---|
| 98 | FacilityId = table.Column<int>(nullable: false),
|
---|
| 99 | Title = table.Column<string>(nullable: true)
|
---|
[a8ccc2c] | 100 | },
|
---|
| 101 | constraints: table =>
|
---|
| 102 | {
|
---|
[d23bf72] | 103 | table.PrimaryKey("PK_HealthcareWorkers", x => x.Id);
|
---|
| 104 | table.ForeignKey(
|
---|
| 105 | name: "FK_HealthcareWorkers_HealthFacilities_FacilityId",
|
---|
| 106 | column: x => x.FacilityId,
|
---|
| 107 | principalTable: "HealthFacilities",
|
---|
| 108 | principalColumn: "Id",
|
---|
| 109 | onDelete: ReferentialAction.Cascade);
|
---|
[a8ccc2c] | 110 | });
|
---|
| 111 |
|
---|
| 112 | migrationBuilder.CreateTable(
|
---|
[1db5673] | 113 | name: "Medicines",
|
---|
[a8ccc2c] | 114 | columns: table => new
|
---|
| 115 | {
|
---|
| 116 | Id = table.Column<int>(nullable: false)
|
---|
[8e74e2f] | 117 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
[1db5673] | 118 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
[d2e69be] | 119 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[1db5673] | 120 | Name = table.Column<string>(nullable: false),
|
---|
| 121 | Strength = table.Column<string>(nullable: false),
|
---|
| 122 | Form = table.Column<string>(nullable: true),
|
---|
| 123 | WayOfIssuing = table.Column<string>(nullable: false),
|
---|
| 124 | Manufacturer = table.Column<string>(nullable: false),
|
---|
| 125 | Price = table.Column<float>(nullable: false),
|
---|
| 126 | Packaging = table.Column<string>(nullable: true),
|
---|
[a8ccc2c] | 127 | PharmacyHeadId = table.Column<int>(nullable: true)
|
---|
| 128 | },
|
---|
| 129 | constraints: table =>
|
---|
| 130 | {
|
---|
[1db5673] | 131 | table.PrimaryKey("PK_Medicines", x => x.Id);
|
---|
[a8ccc2c] | 132 | table.ForeignKey(
|
---|
[1db5673] | 133 | name: "FK_Medicines_PharmacyHeads_PharmacyHeadId",
|
---|
[a8ccc2c] | 134 | column: x => x.PharmacyHeadId,
|
---|
| 135 | principalTable: "PharmacyHeads",
|
---|
| 136 | principalColumn: "Id",
|
---|
| 137 | onDelete: ReferentialAction.Restrict);
|
---|
| 138 | });
|
---|
| 139 |
|
---|
| 140 | migrationBuilder.CreateTable(
|
---|
| 141 | name: "Pharmacies",
|
---|
| 142 | columns: table => new
|
---|
| 143 | {
|
---|
| 144 | Id = table.Column<int>(nullable: false)
|
---|
[8e74e2f] | 145 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
| 146 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
[d2e69be] | 147 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
[d23bf72] | 148 | Name = table.Column<string>(nullable: false),
|
---|
| 149 | Location = table.Column<string>(nullable: false),
|
---|
| 150 | Address = table.Column<string>(nullable: false),
|
---|
[a8ccc2c] | 151 | WorkAllTime = table.Column<bool>(nullable: false),
|
---|
[1db5673] | 152 | PheadId = table.Column<int>(nullable: false)
|
---|
[a8ccc2c] | 153 | },
|
---|
| 154 | constraints: table =>
|
---|
| 155 | {
|
---|
| 156 | table.PrimaryKey("PK_Pharmacies", x => x.Id);
|
---|
| 157 | table.ForeignKey(
|
---|
[1db5673] | 158 | name: "FK_Pharmacies_PharmacyHeads_PheadId",
|
---|
| 159 | column: x => x.PheadId,
|
---|
[a8ccc2c] | 160 | principalTable: "PharmacyHeads",
|
---|
| 161 | principalColumn: "Id",
|
---|
[1db5673] | 162 | onDelete: ReferentialAction.Cascade);
|
---|
| 163 | });
|
---|
| 164 |
|
---|
| 165 | migrationBuilder.CreateTable(
|
---|
| 166 | name: "PharmacyHeadMedicines",
|
---|
| 167 | columns: table => new
|
---|
| 168 | {
|
---|
| 169 | PheadId = table.Column<int>(nullable: false),
|
---|
| 170 | MedicineId = table.Column<int>(nullable: false),
|
---|
| 171 | Id = table.Column<int>(nullable: false),
|
---|
| 172 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
| 173 | DeletedOn = table.Column<DateTime>(nullable: true)
|
---|
| 174 | },
|
---|
| 175 | constraints: table =>
|
---|
| 176 | {
|
---|
| 177 | table.PrimaryKey("PK_PharmacyHeadMedicines", x => new { x.PheadId, x.MedicineId });
|
---|
| 178 | table.ForeignKey(
|
---|
| 179 | name: "FK_PharmacyHeadMedicines_Medicines_MedicineId",
|
---|
| 180 | column: x => x.MedicineId,
|
---|
| 181 | principalTable: "Medicines",
|
---|
| 182 | principalColumn: "Id",
|
---|
| 183 | onDelete: ReferentialAction.Cascade);
|
---|
| 184 | table.ForeignKey(
|
---|
| 185 | name: "FK_PharmacyHeadMedicines_PharmacyHeads_PheadId",
|
---|
| 186 | column: x => x.PheadId,
|
---|
| 187 | principalTable: "PharmacyHeads",
|
---|
| 188 | principalColumn: "Id",
|
---|
| 189 | onDelete: ReferentialAction.Cascade);
|
---|
[a8ccc2c] | 190 | });
|
---|
| 191 |
|
---|
[d23bf72] | 192 | migrationBuilder.CreateTable(
|
---|
| 193 | name: "PHRequests",
|
---|
| 194 | columns: table => new
|
---|
| 195 | {
|
---|
| 196 | Id = table.Column<int>(nullable: false)
|
---|
[8e74e2f] | 197 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
[1db5673] | 198 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
[d23bf72] | 199 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
| 200 | HeadId = table.Column<int>(nullable: false),
|
---|
| 201 | PharmacyId = table.Column<int>(nullable: false)
|
---|
| 202 | },
|
---|
| 203 | constraints: table =>
|
---|
| 204 | {
|
---|
| 205 | table.PrimaryKey("PK_PHRequests", x => x.Id);
|
---|
| 206 | table.ForeignKey(
|
---|
| 207 | name: "FK_PHRequests_PharmacyHeads_HeadId",
|
---|
| 208 | column: x => x.HeadId,
|
---|
| 209 | principalTable: "PharmacyHeads",
|
---|
| 210 | principalColumn: "Id",
|
---|
| 211 | onDelete: ReferentialAction.Cascade);
|
---|
| 212 | table.ForeignKey(
|
---|
| 213 | name: "FK_PHRequests_Pharmacies_PharmacyId",
|
---|
| 214 | column: x => x.PharmacyId,
|
---|
| 215 | principalTable: "Pharmacies",
|
---|
| 216 | principalColumn: "Id",
|
---|
| 217 | onDelete: ReferentialAction.Cascade);
|
---|
| 218 | });
|
---|
| 219 |
|
---|
[a8ccc2c] | 220 | migrationBuilder.CreateIndex(
|
---|
| 221 | name: "IX_HealthcareWorkers_FacilityId",
|
---|
| 222 | table: "HealthcareWorkers",
|
---|
| 223 | column: "FacilityId");
|
---|
| 224 |
|
---|
| 225 | migrationBuilder.CreateIndex(
|
---|
[1db5673] | 226 | name: "IX_Medicines_PharmacyHeadId",
|
---|
| 227 | table: "Medicines",
|
---|
[a8ccc2c] | 228 | column: "PharmacyHeadId");
|
---|
| 229 |
|
---|
| 230 | migrationBuilder.CreateIndex(
|
---|
[1db5673] | 231 | name: "IX_Pharmacies_PheadId",
|
---|
[a8ccc2c] | 232 | table: "Pharmacies",
|
---|
[1db5673] | 233 | column: "PheadId");
|
---|
| 234 |
|
---|
| 235 | migrationBuilder.CreateIndex(
|
---|
| 236 | name: "IX_PharmacyHeadMedicines_MedicineId",
|
---|
| 237 | table: "PharmacyHeadMedicines",
|
---|
| 238 | column: "MedicineId");
|
---|
[a8ccc2c] | 239 |
|
---|
| 240 | migrationBuilder.CreateIndex(
|
---|
[d23bf72] | 241 | name: "IX_PHRequests_HeadId",
|
---|
| 242 | table: "PHRequests",
|
---|
| 243 | column: "HeadId");
|
---|
[a8ccc2c] | 244 |
|
---|
| 245 | migrationBuilder.CreateIndex(
|
---|
[d23bf72] | 246 | name: "IX_PHRequests_PharmacyId",
|
---|
| 247 | table: "PHRequests",
|
---|
| 248 | column: "PharmacyId");
|
---|
[a8ccc2c] | 249 | }
|
---|
| 250 |
|
---|
| 251 | protected override void Down(MigrationBuilder migrationBuilder)
|
---|
| 252 | {
|
---|
[d23bf72] | 253 | migrationBuilder.DropTable(
|
---|
| 254 | name: "HealthcareWorkers");
|
---|
[a8ccc2c] | 255 |
|
---|
[d23bf72] | 256 | migrationBuilder.DropTable(
|
---|
[1db5673] | 257 | name: "Pandemics");
|
---|
[a8ccc2c] | 258 |
|
---|
[d23bf72] | 259 | migrationBuilder.DropTable(
|
---|
[1db5673] | 260 | name: "PharmacyHeadMedicines");
|
---|
[a8ccc2c] | 261 |
|
---|
| 262 | migrationBuilder.DropTable(
|
---|
[d23bf72] | 263 | name: "PHRequests");
|
---|
[a8ccc2c] | 264 |
|
---|
| 265 | migrationBuilder.DropTable(
|
---|
[d23bf72] | 266 | name: "Users");
|
---|
[a8ccc2c] | 267 |
|
---|
| 268 | migrationBuilder.DropTable(
|
---|
| 269 | name: "HealthFacilities");
|
---|
| 270 |
|
---|
| 271 | migrationBuilder.DropTable(
|
---|
| 272 | name: "Medicines");
|
---|
| 273 |
|
---|
| 274 | migrationBuilder.DropTable(
|
---|
| 275 | name: "Pharmacies");
|
---|
| 276 |
|
---|
| 277 | migrationBuilder.DropTable(
|
---|
[d23bf72] | 278 | name: "PharmacyHeads");
|
---|
[a8ccc2c] | 279 | }
|
---|
| 280 | }
|
---|
| 281 | }
|
---|