| 1 | using System;
|
|---|
| 2 | using Microsoft.EntityFrameworkCore.Migrations;
|
|---|
| 3 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|---|
| 4 |
|
|---|
| 5 | #nullable disable
|
|---|
| 6 |
|
|---|
| 7 | namespace iknow_api.Migrations
|
|---|
| 8 | {
|
|---|
| 9 | /// <inheritdoc />
|
|---|
| 10 | public partial class InitialCreate : Migration
|
|---|
| 11 | {
|
|---|
| 12 | /// <inheritdoc />
|
|---|
| 13 | protected override void Up(MigrationBuilder migrationBuilder)
|
|---|
| 14 | {
|
|---|
| 15 | migrationBuilder.CreateTable(
|
|---|
| 16 | name: "User",
|
|---|
| 17 | columns: table => new
|
|---|
| 18 | {
|
|---|
| 19 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 20 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 21 | Name = table.Column<string>(type: "text", nullable: true),
|
|---|
| 22 | Surname = table.Column<string>(type: "text", nullable: true),
|
|---|
| 23 | Index = table.Column<string>(type: "text", nullable: true),
|
|---|
| 24 | Email = table.Column<string>(type: "text", nullable: true),
|
|---|
| 25 | PasswordHash = table.Column<string>(type: "text", nullable: true),
|
|---|
| 26 | Bday = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 27 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 28 | Role = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 29 | },
|
|---|
| 30 | constraints: table =>
|
|---|
| 31 | {
|
|---|
| 32 | table.PrimaryKey("PK_User", x => x.Id);
|
|---|
| 33 | });
|
|---|
| 34 |
|
|---|
| 35 | migrationBuilder.CreateTable(
|
|---|
| 36 | name: "ContactInfo",
|
|---|
| 37 | columns: table => new
|
|---|
| 38 | {
|
|---|
| 39 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 40 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 41 | city = table.Column<string>(type: "text", nullable: true),
|
|---|
| 42 | address = table.Column<string>(type: "text", nullable: true),
|
|---|
| 43 | municipality = table.Column<string>(type: "text", nullable: true),
|
|---|
| 44 | phoneNumber = table.Column<string>(type: "text", nullable: true),
|
|---|
| 45 | microsoftEmail = table.Column<string>(type: "text", nullable: true),
|
|---|
| 46 | UserId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 47 | },
|
|---|
| 48 | constraints: table =>
|
|---|
| 49 | {
|
|---|
| 50 | table.PrimaryKey("PK_ContactInfo", x => x.Id);
|
|---|
| 51 | table.ForeignKey(
|
|---|
| 52 | name: "FK_ContactInfo_User_UserId",
|
|---|
| 53 | column: x => x.UserId,
|
|---|
| 54 | principalTable: "User",
|
|---|
| 55 | principalColumn: "Id",
|
|---|
| 56 | onDelete: ReferentialAction.Cascade);
|
|---|
| 57 | });
|
|---|
| 58 |
|
|---|
| 59 | migrationBuilder.CreateTable(
|
|---|
| 60 | name: "EnrollmentInfo",
|
|---|
| 61 | columns: table => new
|
|---|
| 62 | {
|
|---|
| 63 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 64 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 65 | enrollmentYear = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 66 | major = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 67 | UserId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 68 | },
|
|---|
| 69 | constraints: table =>
|
|---|
| 70 | {
|
|---|
| 71 | table.PrimaryKey("PK_EnrollmentInfo", x => x.Id);
|
|---|
| 72 | table.ForeignKey(
|
|---|
| 73 | name: "FK_EnrollmentInfo_User_UserId",
|
|---|
| 74 | column: x => x.UserId,
|
|---|
| 75 | principalTable: "User",
|
|---|
| 76 | principalColumn: "Id",
|
|---|
| 77 | onDelete: ReferentialAction.Cascade);
|
|---|
| 78 | });
|
|---|
| 79 |
|
|---|
| 80 | migrationBuilder.CreateTable(
|
|---|
| 81 | name: "HighSchool",
|
|---|
| 82 | columns: table => new
|
|---|
| 83 | {
|
|---|
| 84 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 85 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 86 | GPA = table.Column<float>(type: "real", nullable: false),
|
|---|
| 87 | tip = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 88 | UserId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 89 | },
|
|---|
| 90 | constraints: table =>
|
|---|
| 91 | {
|
|---|
| 92 | table.PrimaryKey("PK_HighSchool", x => x.Id);
|
|---|
| 93 | table.ForeignKey(
|
|---|
| 94 | name: "FK_HighSchool_User_UserId",
|
|---|
| 95 | column: x => x.UserId,
|
|---|
| 96 | principalTable: "User",
|
|---|
| 97 | principalColumn: "Id",
|
|---|
| 98 | onDelete: ReferentialAction.Cascade);
|
|---|
| 99 | });
|
|---|
| 100 |
|
|---|
| 101 | migrationBuilder.CreateIndex(
|
|---|
| 102 | name: "IX_ContactInfo_UserId",
|
|---|
| 103 | table: "ContactInfo",
|
|---|
| 104 | column: "UserId");
|
|---|
| 105 |
|
|---|
| 106 | migrationBuilder.CreateIndex(
|
|---|
| 107 | name: "IX_EnrollmentInfo_UserId",
|
|---|
| 108 | table: "EnrollmentInfo",
|
|---|
| 109 | column: "UserId");
|
|---|
| 110 |
|
|---|
| 111 | migrationBuilder.CreateIndex(
|
|---|
| 112 | name: "IX_HighSchool_UserId",
|
|---|
| 113 | table: "HighSchool",
|
|---|
| 114 | column: "UserId");
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | /// <inheritdoc />
|
|---|
| 118 | protected override void Down(MigrationBuilder migrationBuilder)
|
|---|
| 119 | {
|
|---|
| 120 | migrationBuilder.DropTable(
|
|---|
| 121 | name: "ContactInfo");
|
|---|
| 122 |
|
|---|
| 123 | migrationBuilder.DropTable(
|
|---|
| 124 | name: "EnrollmentInfo");
|
|---|
| 125 |
|
|---|
| 126 | migrationBuilder.DropTable(
|
|---|
| 127 | name: "HighSchool");
|
|---|
| 128 |
|
|---|
| 129 | migrationBuilder.DropTable(
|
|---|
| 130 | name: "User");
|
|---|
| 131 | }
|
|---|
| 132 | }
|
|---|
| 133 | }
|
|---|