using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace iknow_api.Migrations
{
///
public partial class InitialCreate : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "User",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column(type: "text", nullable: true),
Surname = table.Column(type: "text", nullable: true),
Index = table.Column(type: "text", nullable: true),
Email = table.Column(type: "text", nullable: true),
PasswordHash = table.Column(type: "text", nullable: true),
Bday = table.Column(type: "timestamp with time zone", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
Role = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_User", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ContactInfo",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
city = table.Column(type: "text", nullable: true),
address = table.Column(type: "text", nullable: true),
municipality = table.Column(type: "text", nullable: true),
phoneNumber = table.Column(type: "text", nullable: true),
microsoftEmail = table.Column(type: "text", nullable: true),
UserId = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ContactInfo", x => x.Id);
table.ForeignKey(
name: "FK_ContactInfo_User_UserId",
column: x => x.UserId,
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "EnrollmentInfo",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
enrollmentYear = table.Column(type: "integer", nullable: false),
major = table.Column(type: "integer", nullable: false),
UserId = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EnrollmentInfo", x => x.Id);
table.ForeignKey(
name: "FK_EnrollmentInfo_User_UserId",
column: x => x.UserId,
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "HighSchool",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GPA = table.Column(type: "real", nullable: false),
tip = table.Column(type: "integer", nullable: false),
UserId = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_HighSchool", x => x.Id);
table.ForeignKey(
name: "FK_HighSchool_User_UserId",
column: x => x.UserId,
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ContactInfo_UserId",
table: "ContactInfo",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_EnrollmentInfo_UserId",
table: "EnrollmentInfo",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_HighSchool_UserId",
table: "HighSchool",
column: "UserId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ContactInfo");
migrationBuilder.DropTable(
name: "EnrollmentInfo");
migrationBuilder.DropTable(
name: "HighSchool");
migrationBuilder.DropTable(
name: "User");
}
}
}