20200517002411_AddUsers.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. #pragma warning disable CS1591
  2. #pragma warning disable SA1601
  3. using System;
  4. using Microsoft.EntityFrameworkCore.Migrations;
  5. namespace Jellyfin.Server.Implementations.Migrations
  6. {
  7. public partial class AddUsers : Migration
  8. {
  9. protected override void Up(MigrationBuilder migrationBuilder)
  10. {
  11. migrationBuilder.CreateTable(
  12. name: "ImageInfo",
  13. schema: "jellyfin",
  14. columns: table => new
  15. {
  16. Id = table.Column<int>(nullable: false)
  17. .Annotation("Sqlite:Autoincrement", true),
  18. Path = table.Column<string>(nullable: false),
  19. LastModified = table.Column<DateTime>(nullable: false)
  20. },
  21. constraints: table =>
  22. {
  23. table.PrimaryKey("PK_ImageInfo", x => x.Id);
  24. });
  25. migrationBuilder.CreateTable(
  26. name: "Users",
  27. schema: "jellyfin",
  28. columns: table => new
  29. {
  30. Id = table.Column<Guid>(nullable: false),
  31. Username = table.Column<string>(maxLength: 255, nullable: false),
  32. Password = table.Column<string>(maxLength: 65535, nullable: true),
  33. EasyPassword = table.Column<string>(maxLength: 65535, nullable: true),
  34. MustUpdatePassword = table.Column<bool>(nullable: false),
  35. AudioLanguagePreference = table.Column<string>(maxLength: 255, nullable: true),
  36. AuthenticationProviderId = table.Column<string>(maxLength: 255, nullable: false),
  37. PasswordResetProviderId = table.Column<string>(maxLength: 255, nullable: false),
  38. InvalidLoginAttemptCount = table.Column<int>(nullable: false),
  39. LastActivityDate = table.Column<DateTime>(nullable: false),
  40. LastLoginDate = table.Column<DateTime>(nullable: false),
  41. LoginAttemptsBeforeLockout = table.Column<int>(nullable: true),
  42. SubtitleMode = table.Column<int>(nullable: false),
  43. PlayDefaultAudioTrack = table.Column<bool>(nullable: false),
  44. SubtitleLanguagePreference = table.Column<string>(maxLength: 255, nullable: true),
  45. DisplayMissingEpisodes = table.Column<bool>(nullable: false),
  46. DisplayCollectionsView = table.Column<bool>(nullable: false),
  47. EnableLocalPassword = table.Column<bool>(nullable: false),
  48. HidePlayedInLatest = table.Column<bool>(nullable: false),
  49. RememberAudioSelections = table.Column<bool>(nullable: false),
  50. RememberSubtitleSelections = table.Column<bool>(nullable: false),
  51. EnableNextEpisodeAutoPlay = table.Column<bool>(nullable: false),
  52. EnableAutoLogin = table.Column<bool>(nullable: false),
  53. EnableUserPreferenceAccess = table.Column<bool>(nullable: false),
  54. MaxParentalAgeRating = table.Column<int>(nullable: true),
  55. RemoteClientBitrateLimit = table.Column<int>(nullable: true),
  56. InternalId = table.Column<long>(nullable: false),
  57. ProfileImageId = table.Column<int>(nullable: true),
  58. RowVersion = table.Column<uint>(nullable: false)
  59. },
  60. constraints: table =>
  61. {
  62. table.PrimaryKey("PK_Users", x => x.Id);
  63. table.ForeignKey(
  64. name: "FK_Users_ImageInfo_ProfileImageId",
  65. column: x => x.ProfileImageId,
  66. principalSchema: "jellyfin",
  67. principalTable: "ImageInfo",
  68. principalColumn: "Id",
  69. onDelete: ReferentialAction.Restrict);
  70. });
  71. migrationBuilder.CreateTable(
  72. name: "AccessSchedule",
  73. schema: "jellyfin",
  74. columns: table => new
  75. {
  76. Id = table.Column<int>(nullable: false)
  77. .Annotation("Sqlite:Autoincrement", true),
  78. UserId = table.Column<Guid>(nullable: false),
  79. DayOfWeek = table.Column<int>(nullable: false),
  80. StartHour = table.Column<double>(nullable: false),
  81. EndHour = table.Column<double>(nullable: false)
  82. },
  83. constraints: table =>
  84. {
  85. table.PrimaryKey("PK_AccessSchedule", x => x.Id);
  86. table.ForeignKey(
  87. name: "FK_AccessSchedule_Users_UserId",
  88. column: x => x.UserId,
  89. principalSchema: "jellyfin",
  90. principalTable: "Users",
  91. principalColumn: "Id",
  92. onDelete: ReferentialAction.Cascade);
  93. });
  94. migrationBuilder.CreateTable(
  95. name: "Groups",
  96. schema: "jellyfin",
  97. columns: table => new
  98. {
  99. Id = table.Column<Guid>(nullable: false),
  100. Name = table.Column<string>(maxLength: 255, nullable: false),
  101. RowVersion = table.Column<uint>(nullable: false),
  102. Group_Groups_Guid = table.Column<Guid>(nullable: true)
  103. },
  104. constraints: table =>
  105. {
  106. table.PrimaryKey("PK_Groups", x => x.Id);
  107. table.ForeignKey(
  108. name: "FK_Groups_Users_Group_Groups_Guid",
  109. column: x => x.Group_Groups_Guid,
  110. principalSchema: "jellyfin",
  111. principalTable: "Users",
  112. principalColumn: "Id",
  113. onDelete: ReferentialAction.Restrict);
  114. });
  115. migrationBuilder.CreateTable(
  116. name: "Permissions",
  117. schema: "jellyfin",
  118. columns: table => new
  119. {
  120. Id = table.Column<int>(nullable: false)
  121. .Annotation("Sqlite:Autoincrement", true),
  122. Kind = table.Column<int>(nullable: false),
  123. Value = table.Column<bool>(nullable: false),
  124. RowVersion = table.Column<uint>(nullable: false),
  125. Permission_GroupPermissions_Id = table.Column<Guid>(nullable: true),
  126. Permission_Permissions_Guid = table.Column<Guid>(nullable: true)
  127. },
  128. constraints: table =>
  129. {
  130. table.PrimaryKey("PK_Permissions", x => x.Id);
  131. table.ForeignKey(
  132. name: "FK_Permissions_Groups_Permission_GroupPermissions_Id",
  133. column: x => x.Permission_GroupPermissions_Id,
  134. principalSchema: "jellyfin",
  135. principalTable: "Groups",
  136. principalColumn: "Id",
  137. onDelete: ReferentialAction.Restrict);
  138. table.ForeignKey(
  139. name: "FK_Permissions_Users_Permission_Permissions_Guid",
  140. column: x => x.Permission_Permissions_Guid,
  141. principalSchema: "jellyfin",
  142. principalTable: "Users",
  143. principalColumn: "Id",
  144. onDelete: ReferentialAction.Restrict);
  145. });
  146. migrationBuilder.CreateTable(
  147. name: "Preferences",
  148. schema: "jellyfin",
  149. columns: table => new
  150. {
  151. Id = table.Column<int>(nullable: false)
  152. .Annotation("Sqlite:Autoincrement", true),
  153. Kind = table.Column<int>(nullable: false),
  154. Value = table.Column<string>(maxLength: 65535, nullable: false),
  155. RowVersion = table.Column<uint>(nullable: false),
  156. Preference_Preferences_Guid = table.Column<Guid>(nullable: true),
  157. Preference_Preferences_Id = table.Column<Guid>(nullable: true)
  158. },
  159. constraints: table =>
  160. {
  161. table.PrimaryKey("PK_Preferences", x => x.Id);
  162. table.ForeignKey(
  163. name: "FK_Preferences_Users_Preference_Preferences_Guid",
  164. column: x => x.Preference_Preferences_Guid,
  165. principalSchema: "jellyfin",
  166. principalTable: "Users",
  167. principalColumn: "Id",
  168. onDelete: ReferentialAction.Restrict);
  169. table.ForeignKey(
  170. name: "FK_Preferences_Groups_Preference_Preferences_Id",
  171. column: x => x.Preference_Preferences_Id,
  172. principalSchema: "jellyfin",
  173. principalTable: "Groups",
  174. principalColumn: "Id",
  175. onDelete: ReferentialAction.Restrict);
  176. });
  177. migrationBuilder.CreateTable(
  178. name: "ProviderMapping",
  179. schema: "jellyfin",
  180. columns: table => new
  181. {
  182. Id = table.Column<int>(nullable: false)
  183. .Annotation("Sqlite:Autoincrement", true),
  184. ProviderName = table.Column<string>(maxLength: 255, nullable: false),
  185. ProviderSecrets = table.Column<string>(maxLength: 65535, nullable: false),
  186. ProviderData = table.Column<string>(maxLength: 65535, nullable: false),
  187. RowVersion = table.Column<uint>(nullable: false),
  188. ProviderMapping_ProviderMappings_Id = table.Column<Guid>(nullable: true)
  189. },
  190. constraints: table =>
  191. {
  192. table.PrimaryKey("PK_ProviderMapping", x => x.Id);
  193. table.ForeignKey(
  194. name: "FK_ProviderMapping_Groups_ProviderMapping_ProviderMappings_Id",
  195. column: x => x.ProviderMapping_ProviderMappings_Id,
  196. principalSchema: "jellyfin",
  197. principalTable: "Groups",
  198. principalColumn: "Id",
  199. onDelete: ReferentialAction.Restrict);
  200. table.ForeignKey(
  201. name: "FK_ProviderMapping_Users_ProviderMapping_ProviderMappings_Id",
  202. column: x => x.ProviderMapping_ProviderMappings_Id,
  203. principalSchema: "jellyfin",
  204. principalTable: "Users",
  205. principalColumn: "Id",
  206. onDelete: ReferentialAction.Restrict);
  207. });
  208. migrationBuilder.CreateIndex(
  209. name: "IX_AccessSchedule_UserId",
  210. schema: "jellyfin",
  211. table: "AccessSchedule",
  212. column: "UserId");
  213. migrationBuilder.CreateIndex(
  214. name: "IX_Groups_Group_Groups_Guid",
  215. schema: "jellyfin",
  216. table: "Groups",
  217. column: "Group_Groups_Guid");
  218. migrationBuilder.CreateIndex(
  219. name: "IX_Permissions_Permission_GroupPermissions_Id",
  220. schema: "jellyfin",
  221. table: "Permissions",
  222. column: "Permission_GroupPermissions_Id");
  223. migrationBuilder.CreateIndex(
  224. name: "IX_Permissions_Permission_Permissions_Guid",
  225. schema: "jellyfin",
  226. table: "Permissions",
  227. column: "Permission_Permissions_Guid");
  228. migrationBuilder.CreateIndex(
  229. name: "IX_Preferences_Preference_Preferences_Guid",
  230. schema: "jellyfin",
  231. table: "Preferences",
  232. column: "Preference_Preferences_Guid");
  233. migrationBuilder.CreateIndex(
  234. name: "IX_Preferences_Preference_Preferences_Id",
  235. schema: "jellyfin",
  236. table: "Preferences",
  237. column: "Preference_Preferences_Id");
  238. migrationBuilder.CreateIndex(
  239. name: "IX_ProviderMapping_ProviderMapping_ProviderMappings_Id",
  240. schema: "jellyfin",
  241. table: "ProviderMapping",
  242. column: "ProviderMapping_ProviderMappings_Id");
  243. migrationBuilder.CreateIndex(
  244. name: "IX_Users_ProfileImageId",
  245. schema: "jellyfin",
  246. table: "Users",
  247. column: "ProfileImageId");
  248. }
  249. protected override void Down(MigrationBuilder migrationBuilder)
  250. {
  251. migrationBuilder.DropTable(
  252. name: "AccessSchedule",
  253. schema: "jellyfin");
  254. migrationBuilder.DropTable(
  255. name: "Permissions",
  256. schema: "jellyfin");
  257. migrationBuilder.DropTable(
  258. name: "Preferences",
  259. schema: "jellyfin");
  260. migrationBuilder.DropTable(
  261. name: "ProviderMapping",
  262. schema: "jellyfin");
  263. migrationBuilder.DropTable(
  264. name: "Groups",
  265. schema: "jellyfin");
  266. migrationBuilder.DropTable(
  267. name: "Users",
  268. schema: "jellyfin");
  269. migrationBuilder.DropTable(
  270. name: "ImageInfo",
  271. schema: "jellyfin");
  272. }
  273. }
  274. }