1
0

20231126234054_ConnectionLogServer.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace Content.Server.Database.Migrations.Postgres
  4. {
  5. /// <inheritdoc />
  6. public partial class ConnectionLogServer : Migration
  7. {
  8. /// <inheritdoc />
  9. protected override void Up(MigrationBuilder migrationBuilder)
  10. {
  11. migrationBuilder.AddColumn<int>(
  12. name: "server_id",
  13. table: "connection_log",
  14. type: "integer",
  15. nullable: false,
  16. defaultValue: 0);
  17. // Note: EF Core automatically makes indexes for all FKs.
  18. // That's really dumb, and there's no simple way to disable this.
  19. // So we drop the index creation command from the migration here,
  20. // as we don't want this index:
  21. // migrationBuilder.CreateIndex(
  22. // name: "IX_connection_log_server_id",
  23. // table: "connection_log",
  24. // column: "server_id");
  25. migrationBuilder.AddForeignKey(
  26. name: "FK_connection_log_server_server_id",
  27. table: "connection_log",
  28. column: "server_id",
  29. principalTable: "server",
  30. principalColumn: "server_id",
  31. onDelete: ReferentialAction.SetNull);
  32. }
  33. /// <inheritdoc />
  34. protected override void Down(MigrationBuilder migrationBuilder)
  35. {
  36. migrationBuilder.DropForeignKey(
  37. name: "FK_connection_log_server_server_id",
  38. table: "connection_log");
  39. // migrationBuilder.DropIndex(
  40. // name: "IX_connection_log_server_id",
  41. // table: "connection_log");
  42. migrationBuilder.DropColumn(
  43. name: "server_id",
  44. table: "connection_log");
  45. }
  46. }
  47. }