source: FarmatikoData/Migrations/20201104230858_InitialMigration.cs@ d23bf72

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

Add SystemService, Auth, fix a lil bugs :)

  • Property mode set to 100644
File size: 12.4 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),
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.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
52 migrationBuilder.CreateTable(
53 name: "Pandemics",
54 columns: table => new
55 {
56 Id = table.Column<int>(nullable: false)
57 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
58 CreatedOn = table.Column<DateTime>(nullable: false),
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: "PharmacyHeads",
76 columns: table => new
77 {
78 Id = table.Column<int>(nullable: false)
79 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
80 CreatedOn = table.Column<DateTime>(nullable: false),
81 DeletedOn = table.Column<DateTime>(nullable: true),
82 Email = table.Column<string>(nullable: false),
83 Name = table.Column<string>(nullable: false),
84 Password = table.Column<string>(nullable: false)
85 },
86 constraints: table =>
87 {
88 table.PrimaryKey("PK_PharmacyHeads", x => x.Id);
89 });
90
91 migrationBuilder.CreateTable(
92 name: "Users",
93 columns: table => new
94 {
95 Id = table.Column<int>(nullable: false)
96 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
97 CreatedOn = table.Column<DateTime>(nullable: false),
98 DeletedOn = table.Column<DateTime>(nullable: true),
99 Name = table.Column<string>(nullable: true),
100 Email = table.Column<string>(nullable: true),
101 Password = table.Column<string>(nullable: true),
102 UserRole = table.Column<int>(nullable: false)
103 },
104 constraints: table =>
105 {
106 table.PrimaryKey("PK_Users", x => x.Id);
107 });
108
109 migrationBuilder.CreateTable(
110 name: "HealthcareWorkers",
111 columns: table => new
112 {
113 Id = table.Column<int>(nullable: false)
114 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
115 CreatedOn = table.Column<DateTime>(nullable: false),
116 DeletedOn = table.Column<DateTime>(nullable: true),
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)
121 },
122 constraints: table =>
123 {
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);
131 });
132
133 migrationBuilder.CreateTable(
134 name: "MedicineLists",
135 columns: table => new
136 {
137 Id = table.Column<int>(nullable: false)
138 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
139 CreatedOn = table.Column<DateTime>(nullable: false),
140 DeletedOn = table.Column<DateTime>(nullable: true),
141 MedicineId = table.Column<int>(nullable: false),
142 HasMedicine = table.Column<bool>(nullable: false),
143 PharmacyHeadId = table.Column<int>(nullable: true)
144 },
145 constraints: table =>
146 {
147 table.PrimaryKey("PK_MedicineLists", x => x.Id);
148 table.ForeignKey(
149 name: "FK_MedicineLists_Medicines_MedicineId",
150 column: x => x.MedicineId,
151 principalTable: "Medicines",
152 principalColumn: "Id",
153 onDelete: ReferentialAction.Cascade);
154 table.ForeignKey(
155 name: "FK_MedicineLists_PharmacyHeads_PharmacyHeadId",
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),
168 CreatedOn = table.Column<DateTime>(nullable: false),
169 DeletedOn = table.Column<DateTime>(nullable: true),
170 Name = table.Column<string>(nullable: false),
171 Location = table.Column<string>(nullable: false),
172 Address = table.Column<string>(nullable: false),
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
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
215 migrationBuilder.CreateIndex(
216 name: "IX_HealthcareWorkers_FacilityId",
217 table: "HealthcareWorkers",
218 column: "FacilityId");
219
220 migrationBuilder.CreateIndex(
221 name: "IX_MedicineLists_MedicineId",
222 table: "MedicineLists",
223 column: "MedicineId");
224
225 migrationBuilder.CreateIndex(
226 name: "IX_MedicineLists_PharmacyHeadId",
227 table: "MedicineLists",
228 column: "PharmacyHeadId");
229
230 migrationBuilder.CreateIndex(
231 name: "IX_Pharmacies_PharmacyHeadId",
232 table: "Pharmacies",
233 column: "PharmacyHeadId");
234
235 migrationBuilder.CreateIndex(
236 name: "IX_PHRequests_HeadId",
237 table: "PHRequests",
238 column: "HeadId");
239
240 migrationBuilder.CreateIndex(
241 name: "IX_PHRequests_PharmacyId",
242 table: "PHRequests",
243 column: "PharmacyId");
244 }
245
246 protected override void Down(MigrationBuilder migrationBuilder)
247 {
248 migrationBuilder.DropTable(
249 name: "HealthcareWorkers");
250
251 migrationBuilder.DropTable(
252 name: "MedicineLists");
253
254 migrationBuilder.DropTable(
255 name: "Pandemics");
256
257 migrationBuilder.DropTable(
258 name: "PHRequests");
259
260 migrationBuilder.DropTable(
261 name: "Users");
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(
273 name: "PharmacyHeads");
274 }
275 }
276}
Note: See TracBrowser for help on using the repository browser.