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.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: true)
|
---|
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.Restrict);
|
---|
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: false),
|
---|
153 | PharmacyHeadId = table.Column<int>(nullable: true)
|
---|
154 | },
|
---|
155 | constraints: table =>
|
---|
156 | {
|
---|
157 | table.PrimaryKey("PK_Pharmacies", x => x.Id);
|
---|
158 | table.ForeignKey(
|
---|
159 | name: "FK_Pharmacies_PharmacyHeads_PharmacyHeadId",
|
---|
160 | column: x => x.PharmacyHeadId,
|
---|
161 | principalTable: "PharmacyHeads",
|
---|
162 | principalColumn: "Id",
|
---|
163 | onDelete: ReferentialAction.Restrict);
|
---|
164 | });
|
---|
165 |
|
---|
166 | migrationBuilder.CreateTable(
|
---|
167 | name: "PharmacyHeadMedicines",
|
---|
168 | columns: table => new
|
---|
169 | {
|
---|
170 | Id = table.Column<int>(nullable: false)
|
---|
171 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
172 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
173 | DeletedOn = table.Column<DateTime>(nullable: true),
|
---|
174 | PheadId = table.Column<int>(nullable: false),
|
---|
175 | HeadId = table.Column<int>(nullable: true),
|
---|
176 | MedicineId = table.Column<int>(nullable: false)
|
---|
177 | },
|
---|
178 | constraints: table =>
|
---|
179 | {
|
---|
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);
|
---|
187 | table.ForeignKey(
|
---|
188 | name: "FK_PharmacyHeadMedicines_Medicines_MedicineId",
|
---|
189 | column: x => x.MedicineId,
|
---|
190 | principalTable: "Medicines",
|
---|
191 | principalColumn: "Id",
|
---|
192 | onDelete: ReferentialAction.Cascade);
|
---|
193 | });
|
---|
194 |
|
---|
195 | migrationBuilder.CreateTable(
|
---|
196 | name: "PHRequests",
|
---|
197 | columns: table => new
|
---|
198 | {
|
---|
199 | Id = table.Column<int>(nullable: false)
|
---|
200 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
---|
201 | CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
|
---|
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 |
|
---|
223 | migrationBuilder.CreateIndex(
|
---|
224 | name: "IX_HealthcareWorkers_FacilityId",
|
---|
225 | table: "HealthcareWorkers",
|
---|
226 | column: "FacilityId");
|
---|
227 |
|
---|
228 | migrationBuilder.CreateIndex(
|
---|
229 | name: "IX_Pharmacies_PharmacyHeadId",
|
---|
230 | table: "Pharmacies",
|
---|
231 | column: "PharmacyHeadId");
|
---|
232 |
|
---|
233 | migrationBuilder.CreateIndex(
|
---|
234 | name: "IX_PharmacyHeadMedicines_HeadId",
|
---|
235 | table: "PharmacyHeadMedicines",
|
---|
236 | column: "HeadId");
|
---|
237 |
|
---|
238 | migrationBuilder.CreateIndex(
|
---|
239 | name: "IX_PharmacyHeadMedicines_MedicineId",
|
---|
240 | table: "PharmacyHeadMedicines",
|
---|
241 | column: "MedicineId");
|
---|
242 |
|
---|
243 | migrationBuilder.CreateIndex(
|
---|
244 | name: "IX_PharmacyHeads_UserId",
|
---|
245 | table: "PharmacyHeads",
|
---|
246 | column: "UserId");
|
---|
247 |
|
---|
248 | migrationBuilder.CreateIndex(
|
---|
249 | name: "IX_PHRequests_HeadId",
|
---|
250 | table: "PHRequests",
|
---|
251 | column: "HeadId");
|
---|
252 |
|
---|
253 | migrationBuilder.CreateIndex(
|
---|
254 | name: "IX_PHRequests_PharmacyId",
|
---|
255 | table: "PHRequests",
|
---|
256 | column: "PharmacyId");
|
---|
257 | }
|
---|
258 |
|
---|
259 | protected override void Down(MigrationBuilder migrationBuilder)
|
---|
260 | {
|
---|
261 | migrationBuilder.DropTable(
|
---|
262 | name: "HealthcareWorkers");
|
---|
263 |
|
---|
264 | migrationBuilder.DropTable(
|
---|
265 | name: "Pandemics");
|
---|
266 |
|
---|
267 | migrationBuilder.DropTable(
|
---|
268 | name: "PharmacyHeadMedicines");
|
---|
269 |
|
---|
270 | migrationBuilder.DropTable(
|
---|
271 | name: "PHRequests");
|
---|
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(
|
---|
283 | name: "PharmacyHeads");
|
---|
284 |
|
---|
285 | migrationBuilder.DropTable(
|
---|
286 | name: "Users");
|
---|
287 | }
|
---|
288 | }
|
---|
289 | }
|
---|