1
0

20220129005644_ServerBanHit.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
  3. #nullable disable
  4. namespace Content.Server.Database.Migrations.Postgres
  5. {
  6. public partial class ServerBanHit : Migration
  7. {
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.AddColumn<byte>(
  11. name: "denied",
  12. table: "connection_log",
  13. type: "smallint",
  14. nullable: true);
  15. migrationBuilder.CreateTable(
  16. name: "server_ban_hit",
  17. columns: table => new
  18. {
  19. server_ban_hit_id = table.Column<int>(type: "integer", nullable: false)
  20. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
  21. ban_id = table.Column<int>(type: "integer", nullable: false),
  22. connection_id = table.Column<int>(type: "integer", nullable: false)
  23. },
  24. constraints: table =>
  25. {
  26. table.PrimaryKey("PK_server_ban_hit", x => x.server_ban_hit_id);
  27. table.ForeignKey(
  28. name: "FK_server_ban_hit_connection_log_connection_id",
  29. column: x => x.connection_id,
  30. principalTable: "connection_log",
  31. principalColumn: "connection_log_id",
  32. onDelete: ReferentialAction.Cascade);
  33. table.ForeignKey(
  34. name: "FK_server_ban_hit_server_ban_ban_id",
  35. column: x => x.ban_id,
  36. principalTable: "server_ban",
  37. principalColumn: "server_ban_id",
  38. onDelete: ReferentialAction.Cascade);
  39. });
  40. migrationBuilder.CreateIndex(
  41. name: "IX_server_ban_hit_ban_id",
  42. table: "server_ban_hit",
  43. column: "ban_id");
  44. migrationBuilder.CreateIndex(
  45. name: "IX_server_ban_hit_connection_id",
  46. table: "server_ban_hit",
  47. column: "connection_id");
  48. }
  49. protected override void Down(MigrationBuilder migrationBuilder)
  50. {
  51. migrationBuilder.DropTable(
  52. name: "server_ban_hit");
  53. migrationBuilder.DropColumn(
  54. name: "denied",
  55. table: "connection_log");
  56. }
  57. }
  58. }