source: iknow-api/Migrations/20251030124902_new.cs@ a92a2a4

Last change on this file since a92a2a4 was 3592476, checked in by imbrsk <boris696boris@…>, 11 months ago

Refactored enums

  • Property mode set to 100644
File size: 7.3 KB
Line 
1using System;
2using Microsoft.EntityFrameworkCore.Migrations;
3using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
4
5#nullable disable
6
7namespace iknow_api.Migrations
8{
9 /// <inheritdoc />
10 public partial class @new : 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 EMBG = table.Column<string>(type: "text", nullable: true),
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
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
124 migrationBuilder.CreateIndex(
125 name: "IX_ContactInfo_UserId",
126 table: "ContactInfo",
127 column: "UserId",
128 unique: true);
129
130 migrationBuilder.CreateIndex(
131 name: "IX_EnrollmentInfo_UserId",
132 table: "EnrollmentInfo",
133 column: "UserId",
134 unique: true);
135
136 migrationBuilder.CreateIndex(
137 name: "IX_HighSchool_UserId",
138 table: "HighSchool",
139 column: "UserId",
140 unique: true);
141
142 migrationBuilder.CreateIndex(
143 name: "IX_RefreshToken_UserId",
144 table: "RefreshToken",
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
160 migrationBuilder.DropTable(
161 name: "RefreshToken");
162
163 migrationBuilder.DropTable(
164 name: "User");
165 }
166 }
167}
Note: See TracBrowser for help on using the repository browser.