20260427054101_AddDonationGoalConfigPeriod.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace Infrastructure.Migrations.AppDb
  4. {
  5. /// <inheritdoc />
  6. public partial class AddDonationGoalConfigPeriod : Migration
  7. {
  8. /// <inheritdoc />
  9. protected override void Up(MigrationBuilder migrationBuilder)
  10. {
  11. migrationBuilder.AddColumn<int>(
  12. name: "Period",
  13. table: "DonationGoalConfig",
  14. type: "int",
  15. nullable: false,
  16. defaultValue: 6);
  17. // 기존 row 보정: StartAt + EndAt 둘 다 있으면 Custom(5), 그 외는 AllTime(6)
  18. migrationBuilder.Sql(@"
  19. UPDATE DonationGoalConfig
  20. SET Period = CASE
  21. WHEN StartAt IS NOT NULL AND EndAt IS NOT NULL THEN 5
  22. ELSE 6
  23. END;
  24. ");
  25. }
  26. /// <inheritdoc />
  27. protected override void Down(MigrationBuilder migrationBuilder)
  28. {
  29. migrationBuilder.DropColumn(
  30. name: "Period",
  31. table: "DonationGoalConfig");
  32. }
  33. }
  34. }