source: FarmatikoData/Migrations/20201111183247_InitialMigration.cs@ 1db5673

Last change on this file since 1db5673 was 1db5673, checked in by DimitarSlezenkovski <dslezenkovski@…>, 21 months ago

Fix bugs, add some more

  • Property mode set to 100644
File size: 12.8 KB
Line 
1using System;
2using Microsoft.EntityFrameworkCore.Migrations;
3using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
4
5namespace 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.IdentityByDefaultColumn),
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: "Pandemics",
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, defaultValueSql: "now()"),
38 DeletedOn = table.Column<DateTime>(nullable: true),
39 Name = table.Column<string>(nullable: false),
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),
44 TotalGlobal = table.Column<long>(nullable: false),
45 DeathsGlobal = table.Column<long>(nullable: false),
46 ActiveGlobal = table.Column<long>(nullable: false)
47 },
48 constraints: table =>
49 {
50 table.PrimaryKey("PK_Pandemics", x => x.Id);
51 });
52
53 migrationBuilder.CreateTable(
54 name: "PharmacyHeads",
55 columns: table => new
56 {
57 Id = table.Column<int>(nullable: false)
58 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
59 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
60 DeletedOn = table.Column<DateTime>(nullable: true),
61 Email = table.Column<string>(nullable: false),
62 Name = table.Column<string>(nullable: false),
63 Password = table.Column<string>(nullable: false)
64 },
65 constraints: table =>
66 {
67 table.PrimaryKey("PK_PharmacyHeads", x => x.Id);
68 });
69
70 migrationBuilder.CreateTable(
71 name: "Users",
72 columns: table => new
73 {
74 Id = table.Column<int>(nullable: false)
75 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
76 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
77 DeletedOn = table.Column<DateTime>(nullable: true),
78 Name = table.Column<string>(nullable: false),
79 Email = table.Column<string>(nullable: false),
80 Password = table.Column<string>(nullable: false),
81 UserRole = table.Column<int>(nullable: false)
82 },
83 constraints: table =>
84 {
85 table.PrimaryKey("PK_Users", x => x.Id);
86 });
87
88 migrationBuilder.CreateTable(
89 name: "HealthcareWorkers",
90 columns: table => new
91 {
92 Id = table.Column<int>(nullable: false)
93 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
94 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
95 DeletedOn = table.Column<DateTime>(nullable: true),
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)
100 },
101 constraints: table =>
102 {
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);
110 });
111
112 migrationBuilder.CreateTable(
113 name: "Medicines",
114 columns: table => new
115 {
116 Id = table.Column<int>(nullable: false)
117 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
118 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
119 DeletedOn = table.Column<DateTime>(nullable: true),
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),
127 PharmacyHeadId = table.Column<int>(nullable: true)
128 },
129 constraints: table =>
130 {
131 table.PrimaryKey("PK_Medicines", x => x.Id);
132 table.ForeignKey(
133 name: "FK_Medicines_PharmacyHeads_PharmacyHeadId",
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)
145 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
146 CreatedOn = table.Column<DateTime>(nullable: false),
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 },
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.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);
190 });
191
192 migrationBuilder.CreateTable(
193 name: "PHRequests",
194 columns: table => new
195 {
196 Id = table.Column<int>(nullable: false)
197 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
198 CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
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
220 migrationBuilder.CreateIndex(
221 name: "IX_HealthcareWorkers_FacilityId",
222 table: "HealthcareWorkers",
223 column: "FacilityId");
224
225 migrationBuilder.CreateIndex(
226 name: "IX_Medicines_PharmacyHeadId",
227 table: "Medicines",
228 column: "PharmacyHeadId");
229
230 migrationBuilder.CreateIndex(
231 name: "IX_Pharmacies_PheadId",
232 table: "Pharmacies",
233 column: "PheadId");
234
235 migrationBuilder.CreateIndex(
236 name: "IX_PharmacyHeadMedicines_MedicineId",
237 table: "PharmacyHeadMedicines",
238 column: "MedicineId");
239
240 migrationBuilder.CreateIndex(
241 name: "IX_PHRequests_HeadId",
242 table: "PHRequests",
243 column: "HeadId");
244
245 migrationBuilder.CreateIndex(
246 name: "IX_PHRequests_PharmacyId",
247 table: "PHRequests",
248 column: "PharmacyId");
249 }
250
251 protected override void Down(MigrationBuilder migrationBuilder)
252 {
253 migrationBuilder.DropTable(
254 name: "HealthcareWorkers");
255
256 migrationBuilder.DropTable(
257 name: "Pandemics");
258
259 migrationBuilder.DropTable(
260 name: "PharmacyHeadMedicines");
261
262 migrationBuilder.DropTable(
263 name: "PHRequests");
264
265 migrationBuilder.DropTable(
266 name: "Users");
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(
278 name: "PharmacyHeads");
279 }
280 }
281}
Note: See TracBrowser for help on using the repository browser.