20240409013837_FixRoundStartDateNullability.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Content.Server.Database.Migrations.Postgres
  5. {
  6. /// <inheritdoc />
  7. public partial class FixRoundStartDateNullability : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.AlterColumn<DateTime>(
  13. name: "start_date",
  14. table: "round",
  15. type: "timestamp with time zone",
  16. nullable: true,
  17. oldClrType: typeof(DateTime),
  18. oldType: "timestamp with time zone",
  19. oldDefaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
  20. migrationBuilder.Sql("UPDATE round SET start_date = NULL WHERE start_date = '-Infinity';");
  21. }
  22. /// <inheritdoc />
  23. protected override void Down(MigrationBuilder migrationBuilder)
  24. {
  25. migrationBuilder.AlterColumn<DateTime>(
  26. name: "start_date",
  27. table: "round",
  28. type: "timestamp with time zone",
  29. nullable: false,
  30. defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
  31. oldClrType: typeof(DateTime),
  32. oldType: "timestamp with time zone",
  33. oldNullable: true);
  34. }
  35. }
  36. }