Files
chapter-organizer/Data/Migrations/20251228200039_RelatedCareers.cs
T
poprhythm 06b2db0b4c Add Related Careers functionality to EventDefinition entity and update related components
Introduced a many-to-many relationship between EventDefinition and Career entities, allowing for the association of multiple careers with an event. Updated the AppDbContext to include a DbSet for Careers and modified the EventDefinitionConfiguration to handle the new relationship. Enhanced the Create, Edit, and Details components to support input and display of related careers, including normalization and processing logic for career names. Updated the database schema to reflect these changes.
2025-12-28 15:22:03 -05:00

73 lines
2.7 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.Migrations
{
/// <inheritdoc />
public partial class RelatedCareers : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Careers",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", maxLength: 200, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Careers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "EventDefinitionCareers",
columns: table => new
{
EventDefinitionId = table.Column<int>(type: "INTEGER", nullable: false),
RelatedCareersId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EventDefinitionCareers", x => new { x.EventDefinitionId, x.RelatedCareersId });
table.ForeignKey(
name: "FK_EventDefinitionCareers_Careers_RelatedCareersId",
column: x => x.RelatedCareersId,
principalTable: "Careers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_EventDefinitionCareers_Events_EventDefinitionId",
column: x => x.EventDefinitionId,
principalTable: "Events",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Careers_Name",
table: "Careers",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_EventDefinitionCareers_RelatedCareersId",
table: "EventDefinitionCareers",
column: "RelatedCareersId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "EventDefinitionCareers");
migrationBuilder.DropTable(
name: "Careers");
}
}
}