157 lines
6.8 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace StudentEnrollmentDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "exampoints",
columns: table => new
{
exampoints_id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
firstexampoints = table.Column<int>(type: "integer", nullable: false),
secondexampoints = table.Column<int>(type: "integer", nullable: false),
thirdexampoints = table.Column<int>(type: "integer", nullable: false),
addpoints = table.Column<int>(type: "integer", nullable: false),
summary = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_exampoints", x => x.exampoints_id);
});
migrationBuilder.CreateTable(
name: "faculty",
columns: table => new
{
faculty_id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_faculty", x => x.faculty_id);
});
migrationBuilder.CreateTable(
name: "student",
columns: table => new
{
student_id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
firstname = table.Column<string>(type: "text", nullable: false),
lastname = table.Column<string>(type: "text", nullable: false),
middlename = table.Column<string>(type: "text", nullable: false),
email = table.Column<string>(type: "text", nullable: false),
tin = table.Column<long>(type: "bigint", nullable: false),
exampointsid = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_student", x => x.student_id);
table.ForeignKey(
name: "FK_student_exampoints_exampointsid",
column: x => x.exampointsid,
principalTable: "exampoints",
principalColumn: "exampoints_id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "course",
columns: table => new
{
course_id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column<string>(type: "text", nullable: false),
facultyid = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_course", x => x.course_id);
table.ForeignKey(
name: "FK_course_faculty_facultyid",
column: x => x.facultyid,
principalTable: "faculty",
principalColumn: "faculty_id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "student_course",
columns: table => new
{
student_course_id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
studentid = table.Column<int>(type: "integer", nullable: false),
courseid = table.Column<int>(type: "integer", nullable: false),
student_id = table.Column<int>(type: "integer", nullable: false),
course_id = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_student_course", x => x.student_course_id);
table.ForeignKey(
name: "FK_student_course_course_course_id",
column: x => x.course_id,
principalTable: "course",
principalColumn: "course_id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_student_course_student_student_id",
column: x => x.student_id,
principalTable: "student",
principalColumn: "student_id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_course_facultyid",
table: "course",
column: "facultyid");
migrationBuilder.CreateIndex(
name: "IX_student_exampointsid",
table: "student",
column: "exampointsid");
migrationBuilder.CreateIndex(
name: "IX_student_course_course_id",
table: "student_course",
column: "course_id");
migrationBuilder.CreateIndex(
name: "IX_student_course_student_id",
table: "student_course",
column: "student_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "student_course");
migrationBuilder.DropTable(
name: "course");
migrationBuilder.DropTable(
name: "student");
migrationBuilder.DropTable(
name: "faculty");
migrationBuilder.DropTable(
name: "exampoints");
}
}
}