Files
chapter-organizer/Data/Migrations/20250825173042_InitialCreate.cs
T

132 lines
5.6 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Events",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
ShortName = table.Column<string>(type: "TEXT", nullable: true),
EventFormat = table.Column<int>(type: "INTEGER", nullable: false),
MinTeamSize = table.Column<int>(type: "INTEGER", nullable: false),
MaxTeamSize = table.Column<int>(type: "INTEGER", nullable: false),
SemifinalistActivity = table.Column<string>(type: "TEXT", nullable: true),
Notes = table.Column<string>(type: "TEXT", nullable: true),
MaxTeamCountState = table.Column<int>(type: "INTEGER", nullable: false),
RegionalEvent = table.Column<bool>(type: "INTEGER", nullable: false),
RegionalPresubmit = table.Column<bool>(type: "INTEGER", nullable: false),
StatePresubmission = table.Column<bool>(type: "INTEGER", nullable: false),
StatePretesting = table.Column<bool>(type: "INTEGER", nullable: false),
StatePreliminaryRound = table.Column<bool>(type: "INTEGER", nullable: false),
Documentation = table.Column<string>(type: "TEXT", nullable: true),
Eligibility = table.Column<string>(type: "TEXT", nullable: false),
Theme = table.Column<string>(type: "TEXT", nullable: true),
Description = table.Column<string>(type: "TEXT", nullable: true),
LevelOfEffort = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Events", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Students",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Students", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Teams",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
CaptainId = table.Column<int>(type: "INTEGER", nullable: true),
TeamNumber = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Teams", x => x.Id);
table.ForeignKey(
name: "FK_Teams_Students_CaptainId",
column: x => x.CaptainId,
principalTable: "Students",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "StudentTeam",
columns: table => new
{
StudentsId = table.Column<int>(type: "INTEGER", nullable: false),
TeamsId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StudentTeam", x => new { x.StudentsId, x.TeamsId });
table.ForeignKey(
name: "FK_StudentTeam_Students_StudentsId",
column: x => x.StudentsId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StudentTeam_Teams_TeamsId",
column: x => x.TeamsId,
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Events_Name",
table: "Events",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_StudentTeam_TeamsId",
table: "StudentTeam",
column: "TeamsId");
migrationBuilder.CreateIndex(
name: "IX_Teams_CaptainId",
table: "Teams",
column: "CaptainId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Events");
migrationBuilder.DropTable(
name: "StudentTeam");
migrationBuilder.DropTable(
name: "Teams");
migrationBuilder.DropTable(
name: "Students");
}
}
}