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