20200929113112_Init.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. namespace Content.Server.Database.Migrations.Sqlite
  4. {
  5. public partial class Init : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "assigned_user_id",
  11. columns: table => new
  12. {
  13. assigned_user_id_id = table.Column<int>(nullable: false)
  14. .Annotation("Sqlite:Autoincrement", true),
  15. user_name = table.Column<string>(nullable: false),
  16. user_id = table.Column<Guid>(nullable: false)
  17. },
  18. constraints: table =>
  19. {
  20. table.PrimaryKey("PK_assigned_user_id", x => x.assigned_user_id_id);
  21. });
  22. migrationBuilder.CreateTable(
  23. name: "ban",
  24. columns: table => new
  25. {
  26. ban_id = table.Column<int>(nullable: false)
  27. .Annotation("Sqlite:Autoincrement", true),
  28. user_id = table.Column<Guid>(nullable: true),
  29. address = table.Column<string>(nullable: true),
  30. ban_time = table.Column<DateTime>(nullable: false),
  31. expiration_time = table.Column<DateTime>(nullable: true),
  32. reason = table.Column<string>(nullable: false),
  33. banning_admin = table.Column<Guid>(nullable: true)
  34. },
  35. constraints: table =>
  36. {
  37. table.PrimaryKey("PK_ban", x => x.ban_id);
  38. });
  39. migrationBuilder.CreateTable(
  40. name: "connection_log",
  41. columns: table => new
  42. {
  43. connection_log_id = table.Column<int>(nullable: false)
  44. .Annotation("Sqlite:Autoincrement", true),
  45. user_id = table.Column<Guid>(nullable: false),
  46. user_name = table.Column<string>(nullable: false),
  47. time = table.Column<DateTime>(nullable: false),
  48. address = table.Column<string>(nullable: false)
  49. },
  50. constraints: table =>
  51. {
  52. table.PrimaryKey("PK_connection_log", x => x.connection_log_id);
  53. });
  54. migrationBuilder.CreateTable(
  55. name: "player",
  56. columns: table => new
  57. {
  58. player_id = table.Column<int>(nullable: false)
  59. .Annotation("Sqlite:Autoincrement", true),
  60. user_id = table.Column<Guid>(nullable: false),
  61. first_seen_time = table.Column<DateTime>(nullable: false),
  62. last_seen_user_name = table.Column<string>(nullable: false),
  63. last_seen_time = table.Column<DateTime>(nullable: false),
  64. last_seen_address = table.Column<string>(nullable: false)
  65. },
  66. constraints: table =>
  67. {
  68. table.PrimaryKey("PK_player", x => x.player_id);
  69. });
  70. migrationBuilder.CreateTable(
  71. name: "preference",
  72. columns: table => new
  73. {
  74. preference_id = table.Column<int>(nullable: false)
  75. .Annotation("Sqlite:Autoincrement", true),
  76. user_id = table.Column<Guid>(nullable: false),
  77. selected_character_slot = table.Column<int>(nullable: false)
  78. },
  79. constraints: table =>
  80. {
  81. table.PrimaryKey("PK_preference", x => x.preference_id);
  82. });
  83. migrationBuilder.CreateTable(
  84. name: "unban",
  85. columns: table => new
  86. {
  87. unban_id = table.Column<int>(nullable: false)
  88. .Annotation("Sqlite:Autoincrement", true),
  89. ban_id = table.Column<int>(nullable: false),
  90. unbanning_admin = table.Column<Guid>(nullable: true),
  91. unban_time = table.Column<DateTime>(nullable: false)
  92. },
  93. constraints: table =>
  94. {
  95. table.PrimaryKey("PK_unban", x => x.unban_id);
  96. table.ForeignKey(
  97. name: "FK_unban_ban_ban_id",
  98. column: x => x.ban_id,
  99. principalTable: "ban",
  100. principalColumn: "ban_id",
  101. onDelete: ReferentialAction.Cascade);
  102. });
  103. migrationBuilder.CreateTable(
  104. name: "profile",
  105. columns: table => new
  106. {
  107. profile_id = table.Column<int>(nullable: false)
  108. .Annotation("Sqlite:Autoincrement", true),
  109. slot = table.Column<int>(nullable: false),
  110. char_name = table.Column<string>(nullable: false),
  111. age = table.Column<int>(nullable: false),
  112. sex = table.Column<string>(nullable: false),
  113. hair_name = table.Column<string>(nullable: false),
  114. hair_color = table.Column<string>(nullable: false),
  115. facial_hair_name = table.Column<string>(nullable: false),
  116. facial_hair_color = table.Column<string>(nullable: false),
  117. eye_color = table.Column<string>(nullable: false),
  118. skin_color = table.Column<string>(nullable: false),
  119. pref_unavailable = table.Column<int>(nullable: false),
  120. preference_id = table.Column<int>(nullable: false)
  121. },
  122. constraints: table =>
  123. {
  124. table.PrimaryKey("PK_profile", x => x.profile_id);
  125. table.ForeignKey(
  126. name: "FK_profile_preference_preference_id",
  127. column: x => x.preference_id,
  128. principalTable: "preference",
  129. principalColumn: "preference_id",
  130. onDelete: ReferentialAction.Cascade);
  131. });
  132. migrationBuilder.CreateTable(
  133. name: "antag",
  134. columns: table => new
  135. {
  136. antag_id = table.Column<int>(nullable: false)
  137. .Annotation("Sqlite:Autoincrement", true),
  138. profile_id = table.Column<int>(nullable: false),
  139. antag_name = table.Column<string>(nullable: false)
  140. },
  141. constraints: table =>
  142. {
  143. table.PrimaryKey("PK_antag", x => x.antag_id);
  144. table.ForeignKey(
  145. name: "FK_antag_profile_profile_id",
  146. column: x => x.profile_id,
  147. principalTable: "profile",
  148. principalColumn: "profile_id",
  149. onDelete: ReferentialAction.Cascade);
  150. });
  151. migrationBuilder.CreateTable(
  152. name: "job",
  153. columns: table => new
  154. {
  155. job_id = table.Column<int>(nullable: false)
  156. .Annotation("Sqlite:Autoincrement", true),
  157. profile_id = table.Column<int>(nullable: false),
  158. job_name = table.Column<string>(nullable: false),
  159. priority = table.Column<int>(nullable: false)
  160. },
  161. constraints: table =>
  162. {
  163. table.PrimaryKey("PK_job", x => x.job_id);
  164. table.ForeignKey(
  165. name: "FK_job_profile_profile_id",
  166. column: x => x.profile_id,
  167. principalTable: "profile",
  168. principalColumn: "profile_id",
  169. onDelete: ReferentialAction.Cascade);
  170. });
  171. migrationBuilder.CreateIndex(
  172. name: "IX_antag_profile_id_antag_name",
  173. table: "antag",
  174. columns: new[] { "profile_id", "antag_name" },
  175. unique: true);
  176. migrationBuilder.CreateIndex(
  177. name: "IX_assigned_user_id_user_id",
  178. table: "assigned_user_id",
  179. column: "user_id",
  180. unique: true);
  181. migrationBuilder.CreateIndex(
  182. name: "IX_assigned_user_id_user_name",
  183. table: "assigned_user_id",
  184. column: "user_name",
  185. unique: true);
  186. migrationBuilder.CreateIndex(
  187. name: "IX_job_profile_id",
  188. table: "job",
  189. column: "profile_id");
  190. migrationBuilder.CreateIndex(
  191. name: "IX_preference_user_id",
  192. table: "preference",
  193. column: "user_id",
  194. unique: true);
  195. migrationBuilder.CreateIndex(
  196. name: "IX_profile_preference_id",
  197. table: "profile",
  198. column: "preference_id");
  199. migrationBuilder.CreateIndex(
  200. name: "IX_profile_slot_preference_id",
  201. table: "profile",
  202. columns: new[] { "slot", "preference_id" },
  203. unique: true);
  204. migrationBuilder.CreateIndex(
  205. name: "IX_unban_ban_id",
  206. table: "unban",
  207. column: "ban_id",
  208. unique: true);
  209. }
  210. protected override void Down(MigrationBuilder migrationBuilder)
  211. {
  212. migrationBuilder.DropTable(
  213. name: "antag");
  214. migrationBuilder.DropTable(
  215. name: "assigned_user_id");
  216. migrationBuilder.DropTable(
  217. name: "connection_log");
  218. migrationBuilder.DropTable(
  219. name: "job");
  220. migrationBuilder.DropTable(
  221. name: "player");
  222. migrationBuilder.DropTable(
  223. name: "unban");
  224. migrationBuilder.DropTable(
  225. name: "profile");
  226. migrationBuilder.DropTable(
  227. name: "ban");
  228. migrationBuilder.DropTable(
  229. name: "preference");
  230. }
  231. }
  232. }