using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations.AppDb
{
///
public partial class AddDonationGoalConfigPeriod : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "Period",
table: "DonationGoalConfig",
type: "int",
nullable: false,
defaultValue: 6);
// 기존 row 보정: StartAt + EndAt 둘 다 있으면 Custom(5), 그 외는 AllTime(6)
migrationBuilder.Sql(@"
UPDATE DonationGoalConfig
SET Period = CASE
WHEN StartAt IS NOT NULL AND EndAt IS NOT NULL THEN 5
ELSE 6
END;
");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Period",
table: "DonationGoalConfig");
}
}
}