source: FarmatikoData/Migrations/20201105063549_InitialMigration.cs@ afc9a9a

Last change on this file since afc9a9a was afc9a9a, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

Add migration and stuff

  • Property mode set to 100644
File size: 12.4 KB
RevLine 
[a8ccc2c]1using System;
2using Microsoft.EntityFrameworkCore.Migrations;
3using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
4
5namespace 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)
16 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
[d23bf72]17 CreatedOn = table.Column<DateTime>(nullable: false),
[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
[d23bf72]31 migrationBuilder.CreateTable(
32 name: "Medicines",
33 columns: table => new
34 {
35 Id = table.Column<int>(nullable: false)
36 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
37 CreatedOn = table.Column<DateTime>(nullable: false),
38 DeletedOn = table.Column<DateTime>(nullable: true),
39 Name = table.Column<string>(nullable: false),
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)
46 },
47 constraints: table =>
48 {
49 table.PrimaryKey("PK_Medicines", x => x.Id);
50 });
51
[a8ccc2c]52 migrationBuilder.CreateTable(
53 name: "Pandemics",
54 columns: table => new
55 {
56 Id = table.Column<int>(nullable: false)
57 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
[d23bf72]58 CreatedOn = table.Column<DateTime>(nullable: false),
[d2e69be]59 DeletedOn = table.Column<DateTime>(nullable: true),
[d23bf72]60 Name = table.Column<string>(nullable: false),
[a8ccc2c]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),
[d23bf72]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 {
71 table.PrimaryKey("PK_Pandemics", x => x.Id);
72 });
73
74 migrationBuilder.CreateTable(
[d23bf72]75 name: "PharmacyHeads",
[a8ccc2c]76 columns: table => new
77 {
78 Id = table.Column<int>(nullable: false)
79 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
[d23bf72]80 CreatedOn = table.Column<DateTime>(nullable: false),
[d2e69be]81 DeletedOn = table.Column<DateTime>(nullable: true),
[d23bf72]82 Email = table.Column<string>(nullable: false),
[a8ccc2c]83 Name = table.Column<string>(nullable: false),
[d23bf72]84 Password = table.Column<string>(nullable: false)
[a8ccc2c]85 },
86 constraints: table =>
87 {
[d23bf72]88 table.PrimaryKey("PK_PharmacyHeads", x => x.Id);
[a8ccc2c]89 });
90
91 migrationBuilder.CreateTable(
[d23bf72]92 name: "Users",
[a8ccc2c]93 columns: table => new
94 {
95 Id = table.Column<int>(nullable: false)
96 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
[d23bf72]97 CreatedOn = table.Column<DateTime>(nullable: false),
[d2e69be]98 DeletedOn = table.Column<DateTime>(nullable: true),
[a8ccc2c]99 Name = table.Column<string>(nullable: true),
[d23bf72]100 Email = table.Column<string>(nullable: true),
101 Password = table.Column<string>(nullable: true),
102 UserRole = table.Column<int>(nullable: false)
[a8ccc2c]103 },
104 constraints: table =>
105 {
[d23bf72]106 table.PrimaryKey("PK_Users", x => x.Id);
[a8ccc2c]107 });
108
109 migrationBuilder.CreateTable(
[d23bf72]110 name: "HealthcareWorkers",
[a8ccc2c]111 columns: table => new
112 {
113 Id = table.Column<int>(nullable: false)
114 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
[d23bf72]115 CreatedOn = table.Column<DateTime>(nullable: false),
[d2e69be]116 DeletedOn = table.Column<DateTime>(nullable: true),
[d23bf72]117 Name = table.Column<string>(nullable: false),
118 Branch = table.Column<string>(nullable: false),
119 FacilityId = table.Column<int>(nullable: false),
120 Title = table.Column<string>(nullable: true)
[a8ccc2c]121 },
122 constraints: table =>
123 {
[d23bf72]124 table.PrimaryKey("PK_HealthcareWorkers", x => x.Id);
125 table.ForeignKey(
126 name: "FK_HealthcareWorkers_HealthFacilities_FacilityId",
127 column: x => x.FacilityId,
128 principalTable: "HealthFacilities",
129 principalColumn: "Id",
130 onDelete: ReferentialAction.Cascade);
[a8ccc2c]131 });
132
133 migrationBuilder.CreateTable(
[afc9a9a]134 name: "MedicineList",
[a8ccc2c]135 columns: table => new
136 {
137 Id = table.Column<int>(nullable: false)
138 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
[d23bf72]139 CreatedOn = table.Column<DateTime>(nullable: false),
[d2e69be]140 DeletedOn = table.Column<DateTime>(nullable: true),
[d23bf72]141 MedicineId = table.Column<int>(nullable: false),
[a8ccc2c]142 HasMedicine = table.Column<bool>(nullable: false),
143 PharmacyHeadId = table.Column<int>(nullable: true)
144 },
145 constraints: table =>
146 {
[afc9a9a]147 table.PrimaryKey("PK_MedicineList", x => x.Id);
[a8ccc2c]148 table.ForeignKey(
[afc9a9a]149 name: "FK_MedicineList_Medicines_MedicineId",
[d23bf72]150 column: x => x.MedicineId,
[a8ccc2c]151 principalTable: "Medicines",
152 principalColumn: "Id",
[d23bf72]153 onDelete: ReferentialAction.Cascade);
[a8ccc2c]154 table.ForeignKey(
[afc9a9a]155 name: "FK_MedicineList_PharmacyHeads_PharmacyHeadId",
[a8ccc2c]156 column: x => x.PharmacyHeadId,
157 principalTable: "PharmacyHeads",
158 principalColumn: "Id",
159 onDelete: ReferentialAction.Restrict);
160 });
161
162 migrationBuilder.CreateTable(
163 name: "Pharmacies",
164 columns: table => new
165 {
166 Id = table.Column<int>(nullable: false)
167 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
[d23bf72]168 CreatedOn = table.Column<DateTime>(nullable: false),
[d2e69be]169 DeletedOn = table.Column<DateTime>(nullable: true),
[d23bf72]170 Name = table.Column<string>(nullable: false),
171 Location = table.Column<string>(nullable: false),
172 Address = table.Column<string>(nullable: false),
[a8ccc2c]173 WorkAllTime = table.Column<bool>(nullable: false),
174 PharmacyHeadId = table.Column<int>(nullable: true)
175 },
176 constraints: table =>
177 {
178 table.PrimaryKey("PK_Pharmacies", x => x.Id);
179 table.ForeignKey(
180 name: "FK_Pharmacies_PharmacyHeads_PharmacyHeadId",
181 column: x => x.PharmacyHeadId,
182 principalTable: "PharmacyHeads",
183 principalColumn: "Id",
184 onDelete: ReferentialAction.Restrict);
185 });
186
[d23bf72]187 migrationBuilder.CreateTable(
188 name: "PHRequests",
189 columns: table => new
190 {
191 Id = table.Column<int>(nullable: false)
192 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
193 CreatedOn = table.Column<DateTime>(nullable: false),
194 DeletedOn = table.Column<DateTime>(nullable: true),
195 HeadId = table.Column<int>(nullable: false),
196 PharmacyId = table.Column<int>(nullable: false)
197 },
198 constraints: table =>
199 {
200 table.PrimaryKey("PK_PHRequests", x => x.Id);
201 table.ForeignKey(
202 name: "FK_PHRequests_PharmacyHeads_HeadId",
203 column: x => x.HeadId,
204 principalTable: "PharmacyHeads",
205 principalColumn: "Id",
206 onDelete: ReferentialAction.Cascade);
207 table.ForeignKey(
208 name: "FK_PHRequests_Pharmacies_PharmacyId",
209 column: x => x.PharmacyId,
210 principalTable: "Pharmacies",
211 principalColumn: "Id",
212 onDelete: ReferentialAction.Cascade);
213 });
214
[a8ccc2c]215 migrationBuilder.CreateIndex(
216 name: "IX_HealthcareWorkers_FacilityId",
217 table: "HealthcareWorkers",
218 column: "FacilityId");
219
220 migrationBuilder.CreateIndex(
[afc9a9a]221 name: "IX_MedicineList_MedicineId",
222 table: "MedicineList",
[d23bf72]223 column: "MedicineId");
[a8ccc2c]224
225 migrationBuilder.CreateIndex(
[afc9a9a]226 name: "IX_MedicineList_PharmacyHeadId",
227 table: "MedicineList",
[a8ccc2c]228 column: "PharmacyHeadId");
229
230 migrationBuilder.CreateIndex(
231 name: "IX_Pharmacies_PharmacyHeadId",
232 table: "Pharmacies",
233 column: "PharmacyHeadId");
234
235 migrationBuilder.CreateIndex(
[d23bf72]236 name: "IX_PHRequests_HeadId",
237 table: "PHRequests",
238 column: "HeadId");
[a8ccc2c]239
240 migrationBuilder.CreateIndex(
[d23bf72]241 name: "IX_PHRequests_PharmacyId",
242 table: "PHRequests",
243 column: "PharmacyId");
[a8ccc2c]244 }
245
246 protected override void Down(MigrationBuilder migrationBuilder)
247 {
[d23bf72]248 migrationBuilder.DropTable(
249 name: "HealthcareWorkers");
[a8ccc2c]250
[d23bf72]251 migrationBuilder.DropTable(
[afc9a9a]252 name: "MedicineList");
[a8ccc2c]253
[d23bf72]254 migrationBuilder.DropTable(
255 name: "Pandemics");
[a8ccc2c]256
257 migrationBuilder.DropTable(
[d23bf72]258 name: "PHRequests");
[a8ccc2c]259
260 migrationBuilder.DropTable(
[d23bf72]261 name: "Users");
[a8ccc2c]262
263 migrationBuilder.DropTable(
264 name: "HealthFacilities");
265
266 migrationBuilder.DropTable(
267 name: "Medicines");
268
269 migrationBuilder.DropTable(
270 name: "Pharmacies");
271
272 migrationBuilder.DropTable(
[d23bf72]273 name: "PharmacyHeads");
[a8ccc2c]274 }
275 }
276}
Note: See TracBrowser for help on using the repository browser.