| 1 | using System;
|
|---|
| 2 | using Microsoft.EntityFrameworkCore.Migrations;
|
|---|
| 3 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|---|
| 4 |
|
|---|
| 5 | #nullable disable
|
|---|
| 6 |
|
|---|
| 7 | #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
|---|
| 8 |
|
|---|
| 9 | namespace iknow_api.Migrations
|
|---|
| 10 | {
|
|---|
| 11 | /// <inheritdoc />
|
|---|
| 12 | public partial class InitialCreate : Migration
|
|---|
| 13 | {
|
|---|
| 14 | /// <inheritdoc />
|
|---|
| 15 | protected override void Up(MigrationBuilder migrationBuilder)
|
|---|
| 16 | {
|
|---|
| 17 | migrationBuilder.CreateTable(
|
|---|
| 18 | name: "ActiveSemesters",
|
|---|
| 19 | columns: table => new
|
|---|
| 20 | {
|
|---|
| 21 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 22 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 23 | Year = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 24 | Type = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 25 | },
|
|---|
| 26 | constraints: table =>
|
|---|
| 27 | {
|
|---|
| 28 | table.PrimaryKey("PK_ActiveSemesters", x => x.Id);
|
|---|
| 29 | });
|
|---|
| 30 |
|
|---|
| 31 | migrationBuilder.CreateTable(
|
|---|
| 32 | name: "Documents",
|
|---|
| 33 | columns: table => new
|
|---|
| 34 | {
|
|---|
| 35 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 36 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 37 | Name = table.Column<string>(type: "text", nullable: true),
|
|---|
| 38 | Body = table.Column<string>(type: "text", nullable: true),
|
|---|
| 39 | Cost = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 40 | },
|
|---|
| 41 | constraints: table =>
|
|---|
| 42 | {
|
|---|
| 43 | table.PrimaryKey("PK_Documents", x => x.Id);
|
|---|
| 44 | });
|
|---|
| 45 |
|
|---|
| 46 | migrationBuilder.CreateTable(
|
|---|
| 47 | name: "Majors",
|
|---|
| 48 | columns: table => new
|
|---|
| 49 | {
|
|---|
| 50 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 51 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 52 | Name = table.Column<string>(type: "text", nullable: true)
|
|---|
| 53 | },
|
|---|
| 54 | constraints: table =>
|
|---|
| 55 | {
|
|---|
| 56 | table.PrimaryKey("PK_Majors", x => x.Id);
|
|---|
| 57 | });
|
|---|
| 58 |
|
|---|
| 59 | migrationBuilder.CreateTable(
|
|---|
| 60 | name: "Subjects",
|
|---|
| 61 | columns: table => new
|
|---|
| 62 | {
|
|---|
| 63 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 64 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 65 | Name = table.Column<string>(type: "text", nullable: true),
|
|---|
| 66 | Code = table.Column<string>(type: "text", nullable: true),
|
|---|
| 67 | AwardedCredits = table.Column<int>(type: "integer", nullable: true),
|
|---|
| 68 | DependencyCredit = table.Column<int>(type: "integer", nullable: true)
|
|---|
| 69 | },
|
|---|
| 70 | constraints: table =>
|
|---|
| 71 | {
|
|---|
| 72 | table.PrimaryKey("PK_Subjects", x => x.Id);
|
|---|
| 73 | });
|
|---|
| 74 |
|
|---|
| 75 | migrationBuilder.CreateTable(
|
|---|
| 76 | name: "User",
|
|---|
| 77 | columns: table => new
|
|---|
| 78 | {
|
|---|
| 79 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 80 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 81 | Name = table.Column<string>(type: "text", nullable: true),
|
|---|
| 82 | EMBG = table.Column<string>(type: "text", nullable: true),
|
|---|
| 83 | Surname = table.Column<string>(type: "text", nullable: true),
|
|---|
| 84 | Index = table.Column<string>(type: "text", nullable: true),
|
|---|
| 85 | Email = table.Column<string>(type: "text", nullable: true),
|
|---|
| 86 | PasswordHash = table.Column<string>(type: "text", nullable: true),
|
|---|
| 87 | MiddleName = table.Column<string>(type: "text", nullable: true),
|
|---|
| 88 | Gender = table.Column<string>(type: "text", nullable: true),
|
|---|
| 89 | Nationality = table.Column<string>(type: "text", nullable: true),
|
|---|
| 90 | Citizenship = table.Column<string>(type: "text", nullable: true),
|
|---|
| 91 | Bday = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 92 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 93 | Role = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 94 | },
|
|---|
| 95 | constraints: table =>
|
|---|
| 96 | {
|
|---|
| 97 | table.PrimaryKey("PK_User", x => x.Id);
|
|---|
| 98 | });
|
|---|
| 99 |
|
|---|
| 100 | migrationBuilder.CreateTable(
|
|---|
| 101 | name: "DependencySubjects",
|
|---|
| 102 | columns: table => new
|
|---|
| 103 | {
|
|---|
| 104 | SubjectId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 105 | DependencyId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 106 | },
|
|---|
| 107 | constraints: table =>
|
|---|
| 108 | {
|
|---|
| 109 | table.PrimaryKey("PK_DependencySubjects", x => new { x.SubjectId, x.DependencyId });
|
|---|
| 110 | table.ForeignKey(
|
|---|
| 111 | name: "FK_DependencySubjects_Subjects_DependencyId",
|
|---|
| 112 | column: x => x.DependencyId,
|
|---|
| 113 | principalTable: "Subjects",
|
|---|
| 114 | principalColumn: "Id",
|
|---|
| 115 | onDelete: ReferentialAction.Restrict);
|
|---|
| 116 | table.ForeignKey(
|
|---|
| 117 | name: "FK_DependencySubjects_Subjects_SubjectId",
|
|---|
| 118 | column: x => x.SubjectId,
|
|---|
| 119 | principalTable: "Subjects",
|
|---|
| 120 | principalColumn: "Id",
|
|---|
| 121 | onDelete: ReferentialAction.Restrict);
|
|---|
| 122 | });
|
|---|
| 123 |
|
|---|
| 124 | migrationBuilder.CreateTable(
|
|---|
| 125 | name: "MajorSubjects",
|
|---|
| 126 | columns: table => new
|
|---|
| 127 | {
|
|---|
| 128 | MajorId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 129 | SubjectId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 130 | MandatorySemester = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 131 | Accreditation = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 132 | },
|
|---|
| 133 | constraints: table =>
|
|---|
| 134 | {
|
|---|
| 135 | table.PrimaryKey("PK_MajorSubjects", x => new { x.MajorId, x.SubjectId });
|
|---|
| 136 | table.ForeignKey(
|
|---|
| 137 | name: "FK_MajorSubjects_Majors_MajorId",
|
|---|
| 138 | column: x => x.MajorId,
|
|---|
| 139 | principalTable: "Majors",
|
|---|
| 140 | principalColumn: "Id",
|
|---|
| 141 | onDelete: ReferentialAction.Cascade);
|
|---|
| 142 | table.ForeignKey(
|
|---|
| 143 | name: "FK_MajorSubjects_Subjects_SubjectId",
|
|---|
| 144 | column: x => x.SubjectId,
|
|---|
| 145 | principalTable: "Subjects",
|
|---|
| 146 | principalColumn: "Id",
|
|---|
| 147 | onDelete: ReferentialAction.Cascade);
|
|---|
| 148 | });
|
|---|
| 149 |
|
|---|
| 150 | migrationBuilder.CreateTable(
|
|---|
| 151 | name: "ContactInfo",
|
|---|
| 152 | columns: table => new
|
|---|
| 153 | {
|
|---|
| 154 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 155 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 156 | City = table.Column<string>(type: "text", nullable: true),
|
|---|
| 157 | Address = table.Column<string>(type: "text", nullable: true),
|
|---|
| 158 | Municipality = table.Column<string>(type: "text", nullable: true),
|
|---|
| 159 | PhoneNumber = table.Column<string>(type: "text", nullable: true),
|
|---|
| 160 | MicrosoftEmail = table.Column<string>(type: "text", nullable: true),
|
|---|
| 161 | UserId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 162 | },
|
|---|
| 163 | constraints: table =>
|
|---|
| 164 | {
|
|---|
| 165 | table.PrimaryKey("PK_ContactInfo", x => x.Id);
|
|---|
| 166 | table.ForeignKey(
|
|---|
| 167 | name: "FK_ContactInfo_User_UserId",
|
|---|
| 168 | column: x => x.UserId,
|
|---|
| 169 | principalTable: "User",
|
|---|
| 170 | principalColumn: "Id",
|
|---|
| 171 | onDelete: ReferentialAction.Cascade);
|
|---|
| 172 | });
|
|---|
| 173 |
|
|---|
| 174 | migrationBuilder.CreateTable(
|
|---|
| 175 | name: "EnrolledSemesters",
|
|---|
| 176 | columns: table => new
|
|---|
| 177 | {
|
|---|
| 178 | Id = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 179 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 180 | QuotaType = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 181 | MajorId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 182 | StudentComment = table.Column<string>(type: "text", nullable: true),
|
|---|
| 183 | Note = table.Column<string>(type: "text", nullable: true),
|
|---|
| 184 | CratedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 185 | LastChange = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 186 | Verified = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 187 | SemesterId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 188 | },
|
|---|
| 189 | constraints: table =>
|
|---|
| 190 | {
|
|---|
| 191 | table.PrimaryKey("PK_EnrolledSemesters", x => x.Id);
|
|---|
| 192 | table.ForeignKey(
|
|---|
| 193 | name: "FK_EnrolledSemesters_ActiveSemesters_Id",
|
|---|
| 194 | column: x => x.Id,
|
|---|
| 195 | principalTable: "ActiveSemesters",
|
|---|
| 196 | principalColumn: "Id",
|
|---|
| 197 | onDelete: ReferentialAction.Restrict);
|
|---|
| 198 | table.ForeignKey(
|
|---|
| 199 | name: "FK_EnrolledSemesters_Majors_MajorId",
|
|---|
| 200 | column: x => x.MajorId,
|
|---|
| 201 | principalTable: "Majors",
|
|---|
| 202 | principalColumn: "Id",
|
|---|
| 203 | onDelete: ReferentialAction.Cascade);
|
|---|
| 204 | table.ForeignKey(
|
|---|
| 205 | name: "FK_EnrolledSemesters_User_UserId",
|
|---|
| 206 | column: x => x.UserId,
|
|---|
| 207 | principalTable: "User",
|
|---|
| 208 | principalColumn: "Id",
|
|---|
| 209 | onDelete: ReferentialAction.Cascade);
|
|---|
| 210 | });
|
|---|
| 211 |
|
|---|
| 212 | migrationBuilder.CreateTable(
|
|---|
| 213 | name: "EnrollmentInfo",
|
|---|
| 214 | columns: table => new
|
|---|
| 215 | {
|
|---|
| 216 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 217 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 218 | EnrollmentYear = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 219 | Quota = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 220 | MajorId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 221 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 222 | StudyType = table.Column<string>(type: "text", nullable: true),
|
|---|
| 223 | StudyStatus = table.Column<string>(type: "text", nullable: true)
|
|---|
| 224 | },
|
|---|
| 225 | constraints: table =>
|
|---|
| 226 | {
|
|---|
| 227 | table.PrimaryKey("PK_EnrollmentInfo", x => x.Id);
|
|---|
| 228 | table.ForeignKey(
|
|---|
| 229 | name: "FK_EnrollmentInfo_Majors_MajorId",
|
|---|
| 230 | column: x => x.MajorId,
|
|---|
| 231 | principalTable: "Majors",
|
|---|
| 232 | principalColumn: "Id",
|
|---|
| 233 | onDelete: ReferentialAction.Cascade);
|
|---|
| 234 | table.ForeignKey(
|
|---|
| 235 | name: "FK_EnrollmentInfo_User_UserId",
|
|---|
| 236 | column: x => x.UserId,
|
|---|
| 237 | principalTable: "User",
|
|---|
| 238 | principalColumn: "Id",
|
|---|
| 239 | onDelete: ReferentialAction.Cascade);
|
|---|
| 240 | });
|
|---|
| 241 |
|
|---|
| 242 | migrationBuilder.CreateTable(
|
|---|
| 243 | name: "HighSchool",
|
|---|
| 244 | columns: table => new
|
|---|
| 245 | {
|
|---|
| 246 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 247 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 248 | GPA = table.Column<float>(type: "real", nullable: false),
|
|---|
| 249 | HighSchoolType = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 250 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 251 | StudyLanguage = table.Column<string>(type: "text", nullable: true)
|
|---|
| 252 | },
|
|---|
| 253 | constraints: table =>
|
|---|
| 254 | {
|
|---|
| 255 | table.PrimaryKey("PK_HighSchool", x => x.Id);
|
|---|
| 256 | table.ForeignKey(
|
|---|
| 257 | name: "FK_HighSchool_User_UserId",
|
|---|
| 258 | column: x => x.UserId,
|
|---|
| 259 | principalTable: "User",
|
|---|
| 260 | principalColumn: "Id",
|
|---|
| 261 | onDelete: ReferentialAction.Cascade);
|
|---|
| 262 | });
|
|---|
| 263 |
|
|---|
| 264 | migrationBuilder.CreateTable(
|
|---|
| 265 | name: "ProfessorSubjects",
|
|---|
| 266 | columns: table => new
|
|---|
| 267 | {
|
|---|
| 268 | ProfessorId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 269 | SemesterId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 270 | SubjectId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 271 | },
|
|---|
| 272 | constraints: table =>
|
|---|
| 273 | {
|
|---|
| 274 | table.PrimaryKey("PK_ProfessorSubjects", x => new { x.ProfessorId, x.SemesterId, x.SubjectId });
|
|---|
| 275 | table.ForeignKey(
|
|---|
| 276 | name: "FK_ProfessorSubjects_ActiveSemesters_SemesterId",
|
|---|
| 277 | column: x => x.SemesterId,
|
|---|
| 278 | principalTable: "ActiveSemesters",
|
|---|
| 279 | principalColumn: "Id",
|
|---|
| 280 | onDelete: ReferentialAction.Cascade);
|
|---|
| 281 | table.ForeignKey(
|
|---|
| 282 | name: "FK_ProfessorSubjects_Subjects_SubjectId",
|
|---|
| 283 | column: x => x.SubjectId,
|
|---|
| 284 | principalTable: "Subjects",
|
|---|
| 285 | principalColumn: "Id",
|
|---|
| 286 | onDelete: ReferentialAction.Cascade);
|
|---|
| 287 | table.ForeignKey(
|
|---|
| 288 | name: "FK_ProfessorSubjects_User_ProfessorId",
|
|---|
| 289 | column: x => x.ProfessorId,
|
|---|
| 290 | principalTable: "User",
|
|---|
| 291 | principalColumn: "Id",
|
|---|
| 292 | onDelete: ReferentialAction.Cascade);
|
|---|
| 293 | });
|
|---|
| 294 |
|
|---|
| 295 | migrationBuilder.CreateTable(
|
|---|
| 296 | name: "RefreshToken",
|
|---|
| 297 | columns: table => new
|
|---|
| 298 | {
|
|---|
| 299 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 300 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 301 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 302 | Token = table.Column<string>(type: "text", nullable: true),
|
|---|
| 303 | ExpiresAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 304 | IsValid = table.Column<bool>(type: "boolean", nullable: false)
|
|---|
| 305 | },
|
|---|
| 306 | constraints: table =>
|
|---|
| 307 | {
|
|---|
| 308 | table.PrimaryKey("PK_RefreshToken", x => x.Id);
|
|---|
| 309 | table.ForeignKey(
|
|---|
| 310 | name: "FK_RefreshToken_User_UserId",
|
|---|
| 311 | column: x => x.UserId,
|
|---|
| 312 | principalTable: "User",
|
|---|
| 313 | principalColumn: "Id",
|
|---|
| 314 | onDelete: ReferentialAction.Cascade);
|
|---|
| 315 | });
|
|---|
| 316 |
|
|---|
| 317 | migrationBuilder.CreateTable(
|
|---|
| 318 | name: "UserDocuments",
|
|---|
| 319 | columns: table => new
|
|---|
| 320 | {
|
|---|
| 321 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 322 | DocumentId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 323 | },
|
|---|
| 324 | constraints: table =>
|
|---|
| 325 | {
|
|---|
| 326 | table.PrimaryKey("PK_UserDocuments", x => new { x.UserId, x.DocumentId });
|
|---|
| 327 | table.ForeignKey(
|
|---|
| 328 | name: "FK_UserDocuments_Documents_DocumentId",
|
|---|
| 329 | column: x => x.DocumentId,
|
|---|
| 330 | principalTable: "Documents",
|
|---|
| 331 | principalColumn: "Id",
|
|---|
| 332 | onDelete: ReferentialAction.Cascade);
|
|---|
| 333 | table.ForeignKey(
|
|---|
| 334 | name: "FK_UserDocuments_User_UserId",
|
|---|
| 335 | column: x => x.UserId,
|
|---|
| 336 | principalTable: "User",
|
|---|
| 337 | principalColumn: "Id",
|
|---|
| 338 | onDelete: ReferentialAction.Cascade);
|
|---|
| 339 | });
|
|---|
| 340 |
|
|---|
| 341 | migrationBuilder.CreateTable(
|
|---|
| 342 | name: "Payments",
|
|---|
| 343 | columns: table => new
|
|---|
| 344 | {
|
|---|
| 345 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 346 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 347 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 348 | EnrollmentInfoId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 349 | },
|
|---|
| 350 | constraints: table =>
|
|---|
| 351 | {
|
|---|
| 352 | table.PrimaryKey("PK_Payments", x => x.Id);
|
|---|
| 353 | table.ForeignKey(
|
|---|
| 354 | name: "FK_Payments_EnrolledSemesters_EnrollmentInfoId",
|
|---|
| 355 | column: x => x.EnrollmentInfoId,
|
|---|
| 356 | principalTable: "EnrolledSemesters",
|
|---|
| 357 | principalColumn: "Id",
|
|---|
| 358 | onDelete: ReferentialAction.Cascade);
|
|---|
| 359 | table.ForeignKey(
|
|---|
| 360 | name: "FK_Payments_User_UserId",
|
|---|
| 361 | column: x => x.UserId,
|
|---|
| 362 | principalTable: "User",
|
|---|
| 363 | principalColumn: "Id",
|
|---|
| 364 | onDelete: ReferentialAction.Cascade);
|
|---|
| 365 | });
|
|---|
| 366 |
|
|---|
| 367 | migrationBuilder.CreateTable(
|
|---|
| 368 | name: "SemesterSubjects",
|
|---|
| 369 | columns: table => new
|
|---|
| 370 | {
|
|---|
| 371 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 372 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 373 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 374 | EnrolledSemesterId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 375 | SubjectId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 376 | ProfessorId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 377 | Signature = table.Column<bool>(type: "boolean", nullable: false)
|
|---|
| 378 | },
|
|---|
| 379 | constraints: table =>
|
|---|
| 380 | {
|
|---|
| 381 | table.PrimaryKey("PK_SemesterSubjects", x => x.Id);
|
|---|
| 382 | table.ForeignKey(
|
|---|
| 383 | name: "FK_SemesterSubjects_EnrolledSemesters_EnrolledSemesterId",
|
|---|
| 384 | column: x => x.EnrolledSemesterId,
|
|---|
| 385 | principalTable: "EnrolledSemesters",
|
|---|
| 386 | principalColumn: "Id",
|
|---|
| 387 | onDelete: ReferentialAction.Restrict);
|
|---|
| 388 | table.ForeignKey(
|
|---|
| 389 | name: "FK_SemesterSubjects_Subjects_SubjectId",
|
|---|
| 390 | column: x => x.SubjectId,
|
|---|
| 391 | principalTable: "Subjects",
|
|---|
| 392 | principalColumn: "Id",
|
|---|
| 393 | onDelete: ReferentialAction.Restrict);
|
|---|
| 394 | table.ForeignKey(
|
|---|
| 395 | name: "FK_SemesterSubjects_User_ProfessorId",
|
|---|
| 396 | column: x => x.ProfessorId,
|
|---|
| 397 | principalTable: "User",
|
|---|
| 398 | principalColumn: "Id",
|
|---|
| 399 | onDelete: ReferentialAction.Restrict);
|
|---|
| 400 | table.ForeignKey(
|
|---|
| 401 | name: "FK_SemesterSubjects_User_UserId",
|
|---|
| 402 | column: x => x.UserId,
|
|---|
| 403 | principalTable: "User",
|
|---|
| 404 | principalColumn: "Id",
|
|---|
| 405 | onDelete: ReferentialAction.Restrict);
|
|---|
| 406 | });
|
|---|
| 407 |
|
|---|
| 408 | migrationBuilder.CreateTable(
|
|---|
| 409 | name: "PassedSubjects",
|
|---|
| 410 | columns: table => new
|
|---|
| 411 | {
|
|---|
| 412 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 413 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 414 | SemesterSubjectId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 415 | Grade = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 416 | DatePassed = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|---|
| 417 | },
|
|---|
| 418 | constraints: table =>
|
|---|
| 419 | {
|
|---|
| 420 | table.PrimaryKey("PK_PassedSubjects", x => x.Id);
|
|---|
| 421 | table.ForeignKey(
|
|---|
| 422 | name: "FK_PassedSubjects_SemesterSubjects_SemesterSubjectId",
|
|---|
| 423 | column: x => x.SemesterSubjectId,
|
|---|
| 424 | principalTable: "SemesterSubjects",
|
|---|
| 425 | principalColumn: "Id",
|
|---|
| 426 | onDelete: ReferentialAction.Cascade);
|
|---|
| 427 | });
|
|---|
| 428 |
|
|---|
| 429 | migrationBuilder.InsertData(
|
|---|
| 430 | table: "Majors",
|
|---|
| 431 | columns: new[] { "Id", "Name" },
|
|---|
| 432 | values: new object[,]
|
|---|
| 433 | {
|
|---|
| 434 | { 1, "PIT" },
|
|---|
| 435 | { 2, "SIIS" },
|
|---|
| 436 | { 3, "SEIS" },
|
|---|
| 437 | { 4, "KN" }
|
|---|
| 438 | });
|
|---|
| 439 |
|
|---|
| 440 | migrationBuilder.CreateIndex(
|
|---|
| 441 | name: "IX_ContactInfo_UserId",
|
|---|
| 442 | table: "ContactInfo",
|
|---|
| 443 | column: "UserId",
|
|---|
| 444 | unique: true);
|
|---|
| 445 |
|
|---|
| 446 | migrationBuilder.CreateIndex(
|
|---|
| 447 | name: "IX_DependencySubjects_DependencyId",
|
|---|
| 448 | table: "DependencySubjects",
|
|---|
| 449 | column: "DependencyId");
|
|---|
| 450 |
|
|---|
| 451 | migrationBuilder.CreateIndex(
|
|---|
| 452 | name: "IX_EnrolledSemesters_MajorId",
|
|---|
| 453 | table: "EnrolledSemesters",
|
|---|
| 454 | column: "MajorId");
|
|---|
| 455 |
|
|---|
| 456 | migrationBuilder.CreateIndex(
|
|---|
| 457 | name: "IX_EnrolledSemesters_UserId",
|
|---|
| 458 | table: "EnrolledSemesters",
|
|---|
| 459 | column: "UserId");
|
|---|
| 460 |
|
|---|
| 461 | migrationBuilder.CreateIndex(
|
|---|
| 462 | name: "IX_EnrollmentInfo_MajorId",
|
|---|
| 463 | table: "EnrollmentInfo",
|
|---|
| 464 | column: "MajorId");
|
|---|
| 465 |
|
|---|
| 466 | migrationBuilder.CreateIndex(
|
|---|
| 467 | name: "IX_EnrollmentInfo_UserId",
|
|---|
| 468 | table: "EnrollmentInfo",
|
|---|
| 469 | column: "UserId",
|
|---|
| 470 | unique: true);
|
|---|
| 471 |
|
|---|
| 472 | migrationBuilder.CreateIndex(
|
|---|
| 473 | name: "IX_HighSchool_UserId",
|
|---|
| 474 | table: "HighSchool",
|
|---|
| 475 | column: "UserId",
|
|---|
| 476 | unique: true);
|
|---|
| 477 |
|
|---|
| 478 | migrationBuilder.CreateIndex(
|
|---|
| 479 | name: "IX_MajorSubjects_SubjectId",
|
|---|
| 480 | table: "MajorSubjects",
|
|---|
| 481 | column: "SubjectId");
|
|---|
| 482 |
|
|---|
| 483 | migrationBuilder.CreateIndex(
|
|---|
| 484 | name: "IX_PassedSubjects_SemesterSubjectId",
|
|---|
| 485 | table: "PassedSubjects",
|
|---|
| 486 | column: "SemesterSubjectId",
|
|---|
| 487 | unique: true);
|
|---|
| 488 |
|
|---|
| 489 | migrationBuilder.CreateIndex(
|
|---|
| 490 | name: "IX_Payments_EnrollmentInfoId",
|
|---|
| 491 | table: "Payments",
|
|---|
| 492 | column: "EnrollmentInfoId");
|
|---|
| 493 |
|
|---|
| 494 | migrationBuilder.CreateIndex(
|
|---|
| 495 | name: "IX_Payments_UserId",
|
|---|
| 496 | table: "Payments",
|
|---|
| 497 | column: "UserId");
|
|---|
| 498 |
|
|---|
| 499 | migrationBuilder.CreateIndex(
|
|---|
| 500 | name: "IX_ProfessorSubjects_SemesterId",
|
|---|
| 501 | table: "ProfessorSubjects",
|
|---|
| 502 | column: "SemesterId");
|
|---|
| 503 |
|
|---|
| 504 | migrationBuilder.CreateIndex(
|
|---|
| 505 | name: "IX_ProfessorSubjects_SubjectId",
|
|---|
| 506 | table: "ProfessorSubjects",
|
|---|
| 507 | column: "SubjectId");
|
|---|
| 508 |
|
|---|
| 509 | migrationBuilder.CreateIndex(
|
|---|
| 510 | name: "IX_RefreshToken_UserId",
|
|---|
| 511 | table: "RefreshToken",
|
|---|
| 512 | column: "UserId");
|
|---|
| 513 |
|
|---|
| 514 | migrationBuilder.CreateIndex(
|
|---|
| 515 | name: "IX_SemesterSubjects_EnrolledSemesterId",
|
|---|
| 516 | table: "SemesterSubjects",
|
|---|
| 517 | column: "EnrolledSemesterId");
|
|---|
| 518 |
|
|---|
| 519 | migrationBuilder.CreateIndex(
|
|---|
| 520 | name: "IX_SemesterSubjects_ProfessorId",
|
|---|
| 521 | table: "SemesterSubjects",
|
|---|
| 522 | column: "ProfessorId");
|
|---|
| 523 |
|
|---|
| 524 | migrationBuilder.CreateIndex(
|
|---|
| 525 | name: "IX_SemesterSubjects_SubjectId",
|
|---|
| 526 | table: "SemesterSubjects",
|
|---|
| 527 | column: "SubjectId");
|
|---|
| 528 |
|
|---|
| 529 | migrationBuilder.CreateIndex(
|
|---|
| 530 | name: "IX_SemesterSubjects_UserId",
|
|---|
| 531 | table: "SemesterSubjects",
|
|---|
| 532 | column: "UserId");
|
|---|
| 533 |
|
|---|
| 534 | migrationBuilder.CreateIndex(
|
|---|
| 535 | name: "IX_UserDocuments_DocumentId",
|
|---|
| 536 | table: "UserDocuments",
|
|---|
| 537 | column: "DocumentId");
|
|---|
| 538 | }
|
|---|
| 539 |
|
|---|
| 540 | /// <inheritdoc />
|
|---|
| 541 | protected override void Down(MigrationBuilder migrationBuilder)
|
|---|
| 542 | {
|
|---|
| 543 | migrationBuilder.DropTable(
|
|---|
| 544 | name: "ContactInfo");
|
|---|
| 545 |
|
|---|
| 546 | migrationBuilder.DropTable(
|
|---|
| 547 | name: "DependencySubjects");
|
|---|
| 548 |
|
|---|
| 549 | migrationBuilder.DropTable(
|
|---|
| 550 | name: "EnrollmentInfo");
|
|---|
| 551 |
|
|---|
| 552 | migrationBuilder.DropTable(
|
|---|
| 553 | name: "HighSchool");
|
|---|
| 554 |
|
|---|
| 555 | migrationBuilder.DropTable(
|
|---|
| 556 | name: "MajorSubjects");
|
|---|
| 557 |
|
|---|
| 558 | migrationBuilder.DropTable(
|
|---|
| 559 | name: "PassedSubjects");
|
|---|
| 560 |
|
|---|
| 561 | migrationBuilder.DropTable(
|
|---|
| 562 | name: "Payments");
|
|---|
| 563 |
|
|---|
| 564 | migrationBuilder.DropTable(
|
|---|
| 565 | name: "ProfessorSubjects");
|
|---|
| 566 |
|
|---|
| 567 | migrationBuilder.DropTable(
|
|---|
| 568 | name: "RefreshToken");
|
|---|
| 569 |
|
|---|
| 570 | migrationBuilder.DropTable(
|
|---|
| 571 | name: "UserDocuments");
|
|---|
| 572 |
|
|---|
| 573 | migrationBuilder.DropTable(
|
|---|
| 574 | name: "SemesterSubjects");
|
|---|
| 575 |
|
|---|
| 576 | migrationBuilder.DropTable(
|
|---|
| 577 | name: "Documents");
|
|---|
| 578 |
|
|---|
| 579 | migrationBuilder.DropTable(
|
|---|
| 580 | name: "EnrolledSemesters");
|
|---|
| 581 |
|
|---|
| 582 | migrationBuilder.DropTable(
|
|---|
| 583 | name: "Subjects");
|
|---|
| 584 |
|
|---|
| 585 | migrationBuilder.DropTable(
|
|---|
| 586 | name: "ActiveSemesters");
|
|---|
| 587 |
|
|---|
| 588 | migrationBuilder.DropTable(
|
|---|
| 589 | name: "Majors");
|
|---|
| 590 |
|
|---|
| 591 | migrationBuilder.DropTable(
|
|---|
| 592 | name: "User");
|
|---|
| 593 | }
|
|---|
| 594 | }
|
|---|
| 595 | }
|
|---|