1
0

20211120202654_AdminLogs.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Content.Server.Database.Migrations.Sqlite
  5. {
  6. public partial class AdminLogs : Migration
  7. {
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.AddUniqueConstraint(
  11. name: "ak_player_user_id",
  12. table: "player",
  13. column: "user_id");
  14. migrationBuilder.CreateTable(
  15. name: "round",
  16. columns: table => new
  17. {
  18. round_id = table.Column<int>(type: "INTEGER", nullable: false)
  19. .Annotation("Sqlite:Autoincrement", true)
  20. },
  21. constraints: table =>
  22. {
  23. table.PrimaryKey("PK_round", x => x.round_id);
  24. });
  25. migrationBuilder.CreateTable(
  26. name: "admin_log",
  27. columns: table => new
  28. {
  29. admin_log_id = table.Column<int>(type: "INTEGER", nullable: false),
  30. round_id = table.Column<int>(type: "INTEGER", nullable: false),
  31. type = table.Column<int>(type: "INTEGER", nullable: false),
  32. date = table.Column<DateTime>(type: "TEXT", nullable: false),
  33. message = table.Column<string>(type: "TEXT", nullable: false),
  34. json = table.Column<string>(type: "jsonb", nullable: false)
  35. },
  36. constraints: table =>
  37. {
  38. table.PrimaryKey("PK_admin_log", x => new { x.admin_log_id, x.round_id });
  39. table.ForeignKey(
  40. name: "FK_admin_log_round_round_id",
  41. column: x => x.round_id,
  42. principalTable: "round",
  43. principalColumn: "round_id",
  44. onDelete: ReferentialAction.Cascade);
  45. });
  46. migrationBuilder.CreateTable(
  47. name: "player_round",
  48. columns: table => new
  49. {
  50. players_id = table.Column<int>(type: "INTEGER", nullable: false),
  51. rounds_id = table.Column<int>(type: "INTEGER", nullable: false)
  52. },
  53. constraints: table =>
  54. {
  55. table.PrimaryKey("PK_player_round", x => new { x.players_id, x.rounds_id });
  56. table.ForeignKey(
  57. name: "FK_player_round_player_players_id",
  58. column: x => x.players_id,
  59. principalTable: "player",
  60. principalColumn: "player_id",
  61. onDelete: ReferentialAction.Cascade);
  62. table.ForeignKey(
  63. name: "FK_player_round_round_rounds_id",
  64. column: x => x.rounds_id,
  65. principalTable: "round",
  66. principalColumn: "round_id",
  67. onDelete: ReferentialAction.Cascade);
  68. });
  69. migrationBuilder.CreateTable(
  70. name: "admin_log_entity",
  71. columns: table => new
  72. {
  73. uid = table.Column<int>(type: "INTEGER", nullable: false)
  74. .Annotation("Sqlite:Autoincrement", true),
  75. name = table.Column<string>(type: "TEXT", nullable: true),
  76. admin_log_id = table.Column<int>(type: "INTEGER", nullable: true),
  77. admin_log_round_id = table.Column<int>(type: "INTEGER", nullable: true)
  78. },
  79. constraints: table =>
  80. {
  81. table.PrimaryKey("PK_admin_log_entity", x => x.uid);
  82. table.ForeignKey(
  83. name: "FK_admin_log_entity_admin_log_admin_log_id_admin_log_round_id",
  84. columns: x => new { x.admin_log_id, x.admin_log_round_id },
  85. principalTable: "admin_log",
  86. principalColumns: new[] { "admin_log_id", "round_id" });
  87. });
  88. migrationBuilder.CreateTable(
  89. name: "admin_log_player",
  90. columns: table => new
  91. {
  92. player_user_id = table.Column<Guid>(type: "TEXT", nullable: false),
  93. log_id = table.Column<int>(type: "INTEGER", nullable: false),
  94. round_id = table.Column<int>(type: "INTEGER", nullable: false)
  95. },
  96. constraints: table =>
  97. {
  98. table.PrimaryKey("PK_admin_log_player", x => new { x.player_user_id, x.log_id, x.round_id });
  99. table.ForeignKey(
  100. name: "FK_admin_log_player_admin_log_log_id_round_id",
  101. columns: x => new { x.log_id, x.round_id },
  102. principalTable: "admin_log",
  103. principalColumns: new[] { "admin_log_id", "round_id" },
  104. onDelete: ReferentialAction.Cascade);
  105. table.ForeignKey(
  106. name: "FK_admin_log_player_player_player_user_id",
  107. column: x => x.player_user_id,
  108. principalTable: "player",
  109. principalColumn: "user_id",
  110. onDelete: ReferentialAction.Cascade);
  111. });
  112. migrationBuilder.CreateIndex(
  113. name: "IX_admin_log_round_id",
  114. table: "admin_log",
  115. column: "round_id");
  116. migrationBuilder.CreateIndex(
  117. name: "IX_admin_log_type",
  118. table: "admin_log",
  119. column: "type");
  120. migrationBuilder.CreateIndex(
  121. name: "IX_admin_log_entity_admin_log_id_admin_log_round_id",
  122. table: "admin_log_entity",
  123. columns: new[] { "admin_log_id", "admin_log_round_id" });
  124. migrationBuilder.CreateIndex(
  125. name: "IX_admin_log_player_log_id_round_id",
  126. table: "admin_log_player",
  127. columns: new[] { "log_id", "round_id" });
  128. migrationBuilder.CreateIndex(
  129. name: "IX_player_round_rounds_id",
  130. table: "player_round",
  131. column: "rounds_id");
  132. }
  133. protected override void Down(MigrationBuilder migrationBuilder)
  134. {
  135. migrationBuilder.DropTable(
  136. name: "admin_log_entity");
  137. migrationBuilder.DropTable(
  138. name: "admin_log_player");
  139. migrationBuilder.DropTable(
  140. name: "player_round");
  141. migrationBuilder.DropTable(
  142. name: "admin_log");
  143. migrationBuilder.DropTable(
  144. name: "round");
  145. migrationBuilder.DropUniqueConstraint(
  146. name: "ak_player_user_id",
  147. table: "player");
  148. }
  149. }
  150. }