using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
{
///
public partial class GraduationClearance : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "GraduationClearanceBatches",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false),
Name = table.Column(type: "varchar(120)", maxLength: 120, nullable: false),
GraduationYear = table.Column(type: "int", nullable: false),
Status = table.Column(type: "int", nullable: false),
Notes = table.Column(type: "varchar(500)", maxLength: 500, nullable: true),
ClosedAt = table.Column(type: "datetime(6)", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
UpdatedAt = table.Column(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GraduationClearanceBatches", x => x.Id);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "GraduationClearanceItems",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false),
GraduationClearanceBatchId = table.Column(type: "char(36)", nullable: false),
Code = table.Column(type: "varchar(30)", maxLength: 30, nullable: false),
Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: false),
ResponsibleUnit = table.Column(type: "varchar(100)", maxLength: 100, nullable: false),
ResponsibleRole = table.Column(type: "varchar(30)", maxLength: 30, nullable: false),
IsRequired = table.Column(type: "tinyint(1)", nullable: false),
SortOrder = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
UpdatedAt = table.Column(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GraduationClearanceItems", x => x.Id);
table.ForeignKey(
name: "FK_GraduationClearanceItems_GraduationClearanceBatches_Graduati~",
column: x => x.GraduationClearanceBatchId,
principalTable: "GraduationClearanceBatches",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "GraduationClearanceRecords",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false),
GraduationClearanceItemId = table.Column(type: "char(36)", nullable: false),
StudentId = table.Column(type: "char(36)", nullable: false),
Status = table.Column(type: "int", nullable: false),
Notes = table.Column(type: "varchar(500)", maxLength: 500, nullable: true),
CompletedAt = table.Column(type: "datetime(6)", nullable: true),
CompletedByUserId = table.Column(type: "char(36)", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
UpdatedAt = table.Column(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GraduationClearanceRecords", x => x.Id);
table.ForeignKey(
name: "FK_GraduationClearanceRecords_GraduationClearanceItems_Graduati~",
column: x => x.GraduationClearanceItemId,
principalTable: "GraduationClearanceItems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GraduationClearanceRecords_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_GraduationClearanceBatches_GraduationYear_Status",
table: "GraduationClearanceBatches",
columns: new[] { "GraduationYear", "Status" });
migrationBuilder.CreateIndex(
name: "IX_GraduationClearanceItems_GraduationClearanceBatchId_Code",
table: "GraduationClearanceItems",
columns: new[] { "GraduationClearanceBatchId", "Code" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_GraduationClearanceRecords_GraduationClearanceItemId_Student~",
table: "GraduationClearanceRecords",
columns: new[] { "GraduationClearanceItemId", "StudentId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_GraduationClearanceRecords_StudentId_Status",
table: "GraduationClearanceRecords",
columns: new[] { "StudentId", "Status" });
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "GraduationClearanceRecords");
migrationBuilder.DropTable(
name: "GraduationClearanceItems");
migrationBuilder.DropTable(
name: "GraduationClearanceBatches");
}
}
}