| [cab02ad] | 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 />
|
|---|
| [3592476] | 10 | public partial class @new : Migration
|
|---|
| [cab02ad] | 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),
|
|---|
| [3592476] | 22 | EMBG = table.Column<string>(type: "text", nullable: true),
|
|---|
| [cab02ad] | 23 | Surname = table.Column<string>(type: "text", nullable: true),
|
|---|
| 24 | Index = table.Column<string>(type: "text", nullable: true),
|
|---|
| 25 | Email = table.Column<string>(type: "text", nullable: true),
|
|---|
| 26 | PasswordHash = table.Column<string>(type: "text", nullable: true),
|
|---|
| 27 | Bday = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 28 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 29 | Role = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 30 | },
|
|---|
| 31 | constraints: table =>
|
|---|
| 32 | {
|
|---|
| 33 | table.PrimaryKey("PK_User", x => x.Id);
|
|---|
| 34 | });
|
|---|
| 35 |
|
|---|
| 36 | migrationBuilder.CreateTable(
|
|---|
| 37 | name: "ContactInfo",
|
|---|
| 38 | columns: table => new
|
|---|
| 39 | {
|
|---|
| 40 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 41 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 42 | city = table.Column<string>(type: "text", nullable: true),
|
|---|
| 43 | address = table.Column<string>(type: "text", nullable: true),
|
|---|
| 44 | municipality = table.Column<string>(type: "text", nullable: true),
|
|---|
| 45 | phoneNumber = table.Column<string>(type: "text", nullable: true),
|
|---|
| 46 | microsoftEmail = table.Column<string>(type: "text", nullable: true),
|
|---|
| 47 | UserId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 48 | },
|
|---|
| 49 | constraints: table =>
|
|---|
| 50 | {
|
|---|
| 51 | table.PrimaryKey("PK_ContactInfo", x => x.Id);
|
|---|
| 52 | table.ForeignKey(
|
|---|
| 53 | name: "FK_ContactInfo_User_UserId",
|
|---|
| 54 | column: x => x.UserId,
|
|---|
| 55 | principalTable: "User",
|
|---|
| 56 | principalColumn: "Id",
|
|---|
| 57 | onDelete: ReferentialAction.Cascade);
|
|---|
| 58 | });
|
|---|
| 59 |
|
|---|
| 60 | migrationBuilder.CreateTable(
|
|---|
| 61 | name: "EnrollmentInfo",
|
|---|
| 62 | columns: table => new
|
|---|
| 63 | {
|
|---|
| 64 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 65 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 66 | enrollmentYear = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 67 | major = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 68 | UserId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 69 | },
|
|---|
| 70 | constraints: table =>
|
|---|
| 71 | {
|
|---|
| 72 | table.PrimaryKey("PK_EnrollmentInfo", x => x.Id);
|
|---|
| 73 | table.ForeignKey(
|
|---|
| 74 | name: "FK_EnrollmentInfo_User_UserId",
|
|---|
| 75 | column: x => x.UserId,
|
|---|
| 76 | principalTable: "User",
|
|---|
| 77 | principalColumn: "Id",
|
|---|
| 78 | onDelete: ReferentialAction.Cascade);
|
|---|
| 79 | });
|
|---|
| 80 |
|
|---|
| 81 | migrationBuilder.CreateTable(
|
|---|
| 82 | name: "HighSchool",
|
|---|
| 83 | columns: table => new
|
|---|
| 84 | {
|
|---|
| 85 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 86 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 87 | GPA = table.Column<float>(type: "real", nullable: false),
|
|---|
| 88 | tip = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 89 | UserId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 90 | },
|
|---|
| 91 | constraints: table =>
|
|---|
| 92 | {
|
|---|
| 93 | table.PrimaryKey("PK_HighSchool", x => x.Id);
|
|---|
| 94 | table.ForeignKey(
|
|---|
| 95 | name: "FK_HighSchool_User_UserId",
|
|---|
| 96 | column: x => x.UserId,
|
|---|
| 97 | principalTable: "User",
|
|---|
| 98 | principalColumn: "Id",
|
|---|
| 99 | onDelete: ReferentialAction.Cascade);
|
|---|
| 100 | });
|
|---|
| 101 |
|
|---|
| [f8af32b] | 102 | migrationBuilder.CreateTable(
|
|---|
| 103 | name: "RefreshToken",
|
|---|
| 104 | columns: table => new
|
|---|
| 105 | {
|
|---|
| 106 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 107 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 108 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 109 | Token = table.Column<string>(type: "text", nullable: true),
|
|---|
| 110 | ExpiresAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 111 | IsValid = table.Column<bool>(type: "boolean", nullable: false)
|
|---|
| 112 | },
|
|---|
| 113 | constraints: table =>
|
|---|
| 114 | {
|
|---|
| 115 | table.PrimaryKey("PK_RefreshToken", x => x.Id);
|
|---|
| 116 | table.ForeignKey(
|
|---|
| 117 | name: "FK_RefreshToken_User_UserId",
|
|---|
| 118 | column: x => x.UserId,
|
|---|
| 119 | principalTable: "User",
|
|---|
| 120 | principalColumn: "Id",
|
|---|
| 121 | onDelete: ReferentialAction.Cascade);
|
|---|
| 122 | });
|
|---|
| 123 |
|
|---|
| [cab02ad] | 124 | migrationBuilder.CreateIndex(
|
|---|
| 125 | name: "IX_ContactInfo_UserId",
|
|---|
| 126 | table: "ContactInfo",
|
|---|
| [f8af32b] | 127 | column: "UserId",
|
|---|
| 128 | unique: true);
|
|---|
| [cab02ad] | 129 |
|
|---|
| 130 | migrationBuilder.CreateIndex(
|
|---|
| 131 | name: "IX_EnrollmentInfo_UserId",
|
|---|
| 132 | table: "EnrollmentInfo",
|
|---|
| [f8af32b] | 133 | column: "UserId",
|
|---|
| 134 | unique: true);
|
|---|
| [cab02ad] | 135 |
|
|---|
| 136 | migrationBuilder.CreateIndex(
|
|---|
| 137 | name: "IX_HighSchool_UserId",
|
|---|
| 138 | table: "HighSchool",
|
|---|
| [f8af32b] | 139 | column: "UserId",
|
|---|
| 140 | unique: true);
|
|---|
| 141 |
|
|---|
| 142 | migrationBuilder.CreateIndex(
|
|---|
| 143 | name: "IX_RefreshToken_UserId",
|
|---|
| 144 | table: "RefreshToken",
|
|---|
| [cab02ad] | 145 | column: "UserId");
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | /// <inheritdoc />
|
|---|
| 149 | protected override void Down(MigrationBuilder migrationBuilder)
|
|---|
| 150 | {
|
|---|
| 151 | migrationBuilder.DropTable(
|
|---|
| 152 | name: "ContactInfo");
|
|---|
| 153 |
|
|---|
| 154 | migrationBuilder.DropTable(
|
|---|
| 155 | name: "EnrollmentInfo");
|
|---|
| 156 |
|
|---|
| 157 | migrationBuilder.DropTable(
|
|---|
| 158 | name: "HighSchool");
|
|---|
| 159 |
|
|---|
| [f8af32b] | 160 | migrationBuilder.DropTable(
|
|---|
| 161 | name: "RefreshToken");
|
|---|
| 162 |
|
|---|
| [cab02ad] | 163 | migrationBuilder.DropTable(
|
|---|
| 164 | name: "User");
|
|---|
| 165 | }
|
|---|
| 166 | }
|
|---|
| 167 | }
|
|---|