Entity-Framework-DBZ/EntityFrameworkCore.Data/Migrations/20250407091019_AddManyToManyRelationshipTeamsMatches.cs

93 lines
2.8 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkCore.Data.Migrations
{
/// <inheritdoc />
public partial class AddManyToManyRelationshipTeamsMatches : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "AwayTeamScore",
table: "Matches",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "HomeTeamScore",
table: "Matches",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_Teams_Name",
table: "Teams",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Matches_AwayTeamId",
table: "Matches",
column: "AwayTeamId");
migrationBuilder.CreateIndex(
name: "IX_Matches_HomeTeamId",
table: "Matches",
column: "HomeTeamId");
migrationBuilder.AddForeignKey(
name: "FK_Matches_Teams_AwayTeamId",
table: "Matches",
column: "AwayTeamId",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Matches_Teams_HomeTeamId",
table: "Matches",
column: "HomeTeamId",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Matches_Teams_AwayTeamId",
table: "Matches");
migrationBuilder.DropForeignKey(
name: "FK_Matches_Teams_HomeTeamId",
table: "Matches");
migrationBuilder.DropIndex(
name: "IX_Teams_Name",
table: "Teams");
migrationBuilder.DropIndex(
name: "IX_Matches_AwayTeamId",
table: "Matches");
migrationBuilder.DropIndex(
name: "IX_Matches_HomeTeamId",
table: "Matches");
migrationBuilder.DropColumn(
name: "AwayTeamScore",
table: "Matches");
migrationBuilder.DropColumn(
name: "HomeTeamScore",
table: "Matches");
}
}
}