1 | using System;
|
---|
2 | using Microsoft.EntityFrameworkCore.Migrations;
|
---|
3 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
---|
4 |
|
---|
5 | namespace FarmatikoData.Migrations
|
---|
6 | {
|
---|
7 | public partial class InitialCreate : 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.SerialColumn),
|
---|
17 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql:"now()"),
|
---|
18 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
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 | },
|
---|
26 | constraints: table =>
|
---|
27 | {
|
---|
28 | table.PrimaryKey("PK_HealthFacilities", x => x.Id);
|
---|
29 | });
|
---|
30 |
|
---|
31 | migrationBuilder.CreateTable(
|
---|
32 | name: "Medicines",
|
---|
33 | columns: table => new
|
---|
34 | {
|
---|
35 | Id = table.Column<int>(nullable: false)
|
---|
36 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
37 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
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 |
|
---|
52 | migrationBuilder.CreateTable(
|
---|
53 | name: "Pandemics",
|
---|
54 | columns: table => new
|
---|
55 | {
|
---|
56 | Id = table.Column<int>(nullable: false)
|
---|
57 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
58 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
59 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
60 | Name = table.Column<string>(nullable: false),
|
---|
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)
|
---|
68 | },
|
---|
69 | constraints: table =>
|
---|
70 | {
|
---|
71 | table.PrimaryKey("PK_Pandemics", x => x.Id);
|
---|
72 | });
|
---|
73 |
|
---|
74 | migrationBuilder.CreateTable(
|
---|
75 | name: "Users",
|
---|
76 | columns: table => new
|
---|
77 | {
|
---|
78 | Id = table.Column<int>(nullable: false)
|
---|
79 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
80 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
81 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
82 | Name = table.Column<string>(nullable: false),
|
---|
83 | Email = table.Column<string>(nullable: false),
|
---|
84 | Password = table.Column<string>(nullable: false),
|
---|
85 | UserRole = table.Column<int>(nullable: false)
|
---|
86 | },
|
---|
87 | constraints: table =>
|
---|
88 | {
|
---|
89 | table.PrimaryKey("PK_Users", x => x.Id);
|
---|
90 | });
|
---|
91 |
|
---|
92 | migrationBuilder.CreateTable(
|
---|
93 | name: "HealthcareWorkers",
|
---|
94 | columns: table => new
|
---|
95 | {
|
---|
96 | Id = table.Column<int>(nullable: false)
|
---|
97 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
98 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
99 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
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)
|
---|
104 | },
|
---|
105 | constraints: table =>
|
---|
106 | {
|
---|
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);
|
---|
114 | });
|
---|
115 |
|
---|
116 | migrationBuilder.CreateTable(
|
---|
117 | name: "PharmacyHeads",
|
---|
118 | columns: table => new
|
---|
119 | {
|
---|
120 | Id = table.Column<int>(nullable: false)
|
---|
121 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
122 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
123 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
124 | Email = table.Column<string>(nullable: false),
|
---|
125 | Name = table.Column<string>(nullable: false),
|
---|
126 | Password = table.Column<string>(nullable: false),
|
---|
127 | UserID = table.Column<int>(nullable: false)
|
---|
128 | },
|
---|
129 | constraints: table =>
|
---|
130 | {
|
---|
131 | table.PrimaryKey("PK_PharmacyHeads", x => x.Id);
|
---|
132 | table.ForeignKey(
|
---|
133 | name: "FK_PharmacyHeads_Users_UserID",
|
---|
134 | column: x => x.UserID,
|
---|
135 | principalTable: "Users",
|
---|
136 | principalColumn: "Id",
|
---|
137 | onDelete: ReferentialAction.Cascade);
|
---|
138 | });
|
---|
139 |
|
---|
140 | migrationBuilder.CreateTable(
|
---|
141 | name: "Pharmacies",
|
---|
142 | columns: table => new
|
---|
143 | {
|
---|
144 | Id = table.Column<int>(nullable: false)
|
---|
145 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
146 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
147 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
148 | Name = table.Column<string>(nullable: false),
|
---|
149 | Location = table.Column<string>(nullable: false),
|
---|
150 | Address = table.Column<string>(nullable: false),
|
---|
151 | WorkAllTime = table.Column<bool>(nullable: false),
|
---|
152 | PheadId = table.Column<int>(nullable: true)
|
---|
153 | },
|
---|
154 | constraints: table =>
|
---|
155 | {
|
---|
156 | table.PrimaryKey("PK_Pharmacies", x => x.Id);
|
---|
157 | table.ForeignKey(
|
---|
158 | name: "FK_Pharmacies_PharmacyHeads_PheadId",
|
---|
159 | column: x => x.PheadId,
|
---|
160 | principalTable: "PharmacyHeads",
|
---|
161 | principalColumn: "Id",
|
---|
162 | onDelete: ReferentialAction.Restrict);
|
---|
163 | });
|
---|
164 |
|
---|
165 | migrationBuilder.CreateTable(
|
---|
166 | name: "PharmacyHeadMedicines",
|
---|
167 | columns: table => new
|
---|
168 | {
|
---|
169 | Id = table.Column<int>(nullable: false)
|
---|
170 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
171 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
172 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
173 | PheadId = table.Column<int>(nullable: false),
|
---|
174 | HeadId = table.Column<int>(nullable: true),
|
---|
175 | MedicineId = table.Column<int>(nullable: false)
|
---|
176 | },
|
---|
177 | constraints: table =>
|
---|
178 | {
|
---|
179 | table.PrimaryKey("PK_PharmacyHeadMedicines", x => x.Id);
|
---|
180 | table.ForeignKey(
|
---|
181 | name: "FK_PharmacyHeadMedicines_PharmacyHeads_HeadId",
|
---|
182 | column: x => x.HeadId,
|
---|
183 | principalTable: "PharmacyHeads",
|
---|
184 | principalColumn: "Id",
|
---|
185 | onDelete: ReferentialAction.Restrict);
|
---|
186 | table.ForeignKey(
|
---|
187 | name: "FK_PharmacyHeadMedicines_Medicines_MedicineId",
|
---|
188 | column: x => x.MedicineId,
|
---|
189 | principalTable: "Medicines",
|
---|
190 | principalColumn: "Id",
|
---|
191 | onDelete: ReferentialAction.Cascade);
|
---|
192 | });
|
---|
193 |
|
---|
194 | migrationBuilder.CreateTable(
|
---|
195 | name: "PHRequests",
|
---|
196 | columns: table => new
|
---|
197 | {
|
---|
198 | Id = table.Column<int>(nullable: false)
|
---|
199 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
200 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
201 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
202 | HeadId = table.Column<int>(nullable: true),
|
---|
203 | PharmacyId = table.Column<int>(nullable: true)
|
---|
204 | },
|
---|
205 | constraints: table =>
|
---|
206 | {
|
---|
207 | table.PrimaryKey("PK_PHRequests", x => x.Id);
|
---|
208 | table.ForeignKey(
|
---|
209 | name: "FK_PHRequests_PharmacyHeads_HeadId",
|
---|
210 | column: x => x.HeadId,
|
---|
211 | principalTable: "PharmacyHeads",
|
---|
212 | principalColumn: "Id",
|
---|
213 | onDelete: ReferentialAction.Restrict);
|
---|
214 | table.ForeignKey(
|
---|
215 | name: "FK_PHRequests_Pharmacies_PharmacyId",
|
---|
216 | column: x => x.PharmacyId,
|
---|
217 | principalTable: "Pharmacies",
|
---|
218 | principalColumn: "Id",
|
---|
219 | onDelete: ReferentialAction.Restrict);
|
---|
220 | });
|
---|
221 |
|
---|
222 | migrationBuilder.CreateIndex(
|
---|
223 | name: "IX_HealthcareWorkers_FacilityId",
|
---|
224 | table: "HealthcareWorkers",
|
---|
225 | column: "FacilityId");
|
---|
226 |
|
---|
227 | migrationBuilder.CreateIndex(
|
---|
228 | name: "IX_Pharmacies_PheadId",
|
---|
229 | table: "Pharmacies",
|
---|
230 | column: "PheadId");
|
---|
231 |
|
---|
232 | migrationBuilder.CreateIndex(
|
---|
233 | name: "IX_PharmacyHeadMedicines_HeadId",
|
---|
234 | table: "PharmacyHeadMedicines",
|
---|
235 | column: "HeadId");
|
---|
236 |
|
---|
237 | migrationBuilder.CreateIndex(
|
---|
238 | name: "IX_PharmacyHeadMedicines_MedicineId",
|
---|
239 | table: "PharmacyHeadMedicines",
|
---|
240 | column: "MedicineId");
|
---|
241 |
|
---|
242 | migrationBuilder.CreateIndex(
|
---|
243 | name: "IX_PharmacyHeads_UserID",
|
---|
244 | table: "PharmacyHeads",
|
---|
245 | column: "UserID");
|
---|
246 |
|
---|
247 | migrationBuilder.CreateIndex(
|
---|
248 | name: "IX_PHRequests_HeadId",
|
---|
249 | table: "PHRequests",
|
---|
250 | column: "HeadId");
|
---|
251 |
|
---|
252 | migrationBuilder.CreateIndex(
|
---|
253 | name: "IX_PHRequests_PharmacyId",
|
---|
254 | table: "PHRequests",
|
---|
255 | column: "PharmacyId");
|
---|
256 | }
|
---|
257 |
|
---|
258 | protected override void Down(MigrationBuilder migrationBuilder)
|
---|
259 | {
|
---|
260 | migrationBuilder.DropTable(
|
---|
261 | name: "HealthcareWorkers");
|
---|
262 |
|
---|
263 | migrationBuilder.DropTable(
|
---|
264 | name: "Pandemics");
|
---|
265 |
|
---|
266 | migrationBuilder.DropTable(
|
---|
267 | name: "PharmacyHeadMedicines");
|
---|
268 |
|
---|
269 | migrationBuilder.DropTable(
|
---|
270 | name: "PHRequests");
|
---|
271 |
|
---|
272 | migrationBuilder.DropTable(
|
---|
273 | name: "HealthFacilities");
|
---|
274 |
|
---|
275 | migrationBuilder.DropTable(
|
---|
276 | name: "Medicines");
|
---|
277 |
|
---|
278 | migrationBuilder.DropTable(
|
---|
279 | name: "Pharmacies");
|
---|
280 |
|
---|
281 | migrationBuilder.DropTable(
|
---|
282 | name: "PharmacyHeads");
|
---|
283 |
|
---|
284 | migrationBuilder.DropTable(
|
---|
285 | name: "Users");
|
---|
286 | }
|
---|
287 | }
|
---|
288 | }
|
---|