20200529171409_AddUsers.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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>(maxLength: 512, 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: true),
  40. LastLoginDate = table.Column<DateTime>(nullable: true),
  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. SyncPlayAccess = table.Column<int>(nullable: false),
  59. RowVersion = table.Column<uint>(nullable: false)
  60. },
  61. constraints: table =>
  62. {
  63. table.PrimaryKey("PK_Users", x => x.Id);
  64. table.ForeignKey(
  65. name: "FK_Users_ImageInfo_ProfileImageId",
  66. column: x => x.ProfileImageId,
  67. principalSchema: "jellyfin",
  68. principalTable: "ImageInfo",
  69. principalColumn: "Id",
  70. onDelete: ReferentialAction.Restrict);
  71. });
  72. migrationBuilder.CreateTable(
  73. name: "AccessSchedule",
  74. schema: "jellyfin",
  75. columns: table => new
  76. {
  77. Id = table.Column<int>(nullable: false)
  78. .Annotation("Sqlite:Autoincrement", true),
  79. UserId = table.Column<Guid>(nullable: false),
  80. DayOfWeek = table.Column<int>(nullable: false),
  81. StartHour = table.Column<double>(nullable: false),
  82. EndHour = table.Column<double>(nullable: false)
  83. },
  84. constraints: table =>
  85. {
  86. table.PrimaryKey("PK_AccessSchedule", x => x.Id);
  87. table.ForeignKey(
  88. name: "FK_AccessSchedule_Users_UserId",
  89. column: x => x.UserId,
  90. principalSchema: "jellyfin",
  91. principalTable: "Users",
  92. principalColumn: "Id",
  93. onDelete: ReferentialAction.Cascade);
  94. });
  95. migrationBuilder.CreateTable(
  96. name: "Groups",
  97. schema: "jellyfin",
  98. columns: table => new
  99. {
  100. Id = table.Column<Guid>(nullable: false),
  101. Name = table.Column<string>(maxLength: 255, nullable: false),
  102. RowVersion = table.Column<uint>(nullable: false),
  103. Group_Groups_Guid = table.Column<Guid>(nullable: true)
  104. },
  105. constraints: table =>
  106. {
  107. table.PrimaryKey("PK_Groups", x => x.Id);
  108. table.ForeignKey(
  109. name: "FK_Groups_Users_Group_Groups_Guid",
  110. column: x => x.Group_Groups_Guid,
  111. principalSchema: "jellyfin",
  112. principalTable: "Users",
  113. principalColumn: "Id",
  114. onDelete: ReferentialAction.Restrict);
  115. });
  116. migrationBuilder.CreateTable(
  117. name: "Permissions",
  118. schema: "jellyfin",
  119. columns: table => new
  120. {
  121. Id = table.Column<int>(nullable: false)
  122. .Annotation("Sqlite:Autoincrement", true),
  123. Kind = table.Column<int>(nullable: false),
  124. Value = table.Column<bool>(nullable: false),
  125. RowVersion = table.Column<uint>(nullable: false),
  126. Permission_GroupPermissions_Id = table.Column<Guid>(nullable: true),
  127. Permission_Permissions_Guid = table.Column<Guid>(nullable: true)
  128. },
  129. constraints: table =>
  130. {
  131. table.PrimaryKey("PK_Permissions", x => x.Id);
  132. table.ForeignKey(
  133. name: "FK_Permissions_Groups_Permission_GroupPermissions_Id",
  134. column: x => x.Permission_GroupPermissions_Id,
  135. principalSchema: "jellyfin",
  136. principalTable: "Groups",
  137. principalColumn: "Id",
  138. onDelete: ReferentialAction.Restrict);
  139. table.ForeignKey(
  140. name: "FK_Permissions_Users_Permission_Permissions_Guid",
  141. column: x => x.Permission_Permissions_Guid,
  142. principalSchema: "jellyfin",
  143. principalTable: "Users",
  144. principalColumn: "Id",
  145. onDelete: ReferentialAction.Restrict);
  146. });
  147. migrationBuilder.CreateTable(
  148. name: "Preferences",
  149. schema: "jellyfin",
  150. columns: table => new
  151. {
  152. Id = table.Column<int>(nullable: false)
  153. .Annotation("Sqlite:Autoincrement", true),
  154. Kind = table.Column<int>(nullable: false),
  155. Value = table.Column<string>(maxLength: 65535, nullable: false),
  156. RowVersion = table.Column<uint>(nullable: false),
  157. Preference_Preferences_Guid = table.Column<Guid>(nullable: true),
  158. Preference_Preferences_Id = table.Column<Guid>(nullable: true)
  159. },
  160. constraints: table =>
  161. {
  162. table.PrimaryKey("PK_Preferences", x => x.Id);
  163. table.ForeignKey(
  164. name: "FK_Preferences_Users_Preference_Preferences_Guid",
  165. column: x => x.Preference_Preferences_Guid,
  166. principalSchema: "jellyfin",
  167. principalTable: "Users",
  168. principalColumn: "Id",
  169. onDelete: ReferentialAction.Restrict);
  170. table.ForeignKey(
  171. name: "FK_Preferences_Groups_Preference_Preferences_Id",
  172. column: x => x.Preference_Preferences_Id,
  173. principalSchema: "jellyfin",
  174. principalTable: "Groups",
  175. principalColumn: "Id",
  176. onDelete: ReferentialAction.Restrict);
  177. });
  178. migrationBuilder.CreateTable(
  179. name: "ProviderMapping",
  180. schema: "jellyfin",
  181. columns: table => new
  182. {
  183. Id = table.Column<int>(nullable: false)
  184. .Annotation("Sqlite:Autoincrement", true),
  185. ProviderName = table.Column<string>(maxLength: 255, nullable: false),
  186. ProviderSecrets = table.Column<string>(maxLength: 65535, nullable: false),
  187. ProviderData = table.Column<string>(maxLength: 65535, nullable: false),
  188. RowVersion = table.Column<uint>(nullable: false),
  189. ProviderMapping_ProviderMappings_Id = table.Column<Guid>(nullable: true)
  190. },
  191. constraints: table =>
  192. {
  193. table.PrimaryKey("PK_ProviderMapping", x => x.Id);
  194. table.ForeignKey(
  195. name: "FK_ProviderMapping_Groups_ProviderMapping_ProviderMappings_Id",
  196. column: x => x.ProviderMapping_ProviderMappings_Id,
  197. principalSchema: "jellyfin",
  198. principalTable: "Groups",
  199. principalColumn: "Id",
  200. onDelete: ReferentialAction.Restrict);
  201. table.ForeignKey(
  202. name: "FK_ProviderMapping_Users_ProviderMapping_ProviderMappings_Id",
  203. column: x => x.ProviderMapping_ProviderMappings_Id,
  204. principalSchema: "jellyfin",
  205. principalTable: "Users",
  206. principalColumn: "Id",
  207. onDelete: ReferentialAction.Restrict);
  208. });
  209. migrationBuilder.CreateIndex(
  210. name: "IX_AccessSchedule_UserId",
  211. schema: "jellyfin",
  212. table: "AccessSchedule",
  213. column: "UserId");
  214. migrationBuilder.CreateIndex(
  215. name: "IX_Groups_Group_Groups_Guid",
  216. schema: "jellyfin",
  217. table: "Groups",
  218. column: "Group_Groups_Guid");
  219. migrationBuilder.CreateIndex(
  220. name: "IX_Permissions_Permission_GroupPermissions_Id",
  221. schema: "jellyfin",
  222. table: "Permissions",
  223. column: "Permission_GroupPermissions_Id");
  224. migrationBuilder.CreateIndex(
  225. name: "IX_Permissions_Permission_Permissions_Guid",
  226. schema: "jellyfin",
  227. table: "Permissions",
  228. column: "Permission_Permissions_Guid");
  229. migrationBuilder.CreateIndex(
  230. name: "IX_Preferences_Preference_Preferences_Guid",
  231. schema: "jellyfin",
  232. table: "Preferences",
  233. column: "Preference_Preferences_Guid");
  234. migrationBuilder.CreateIndex(
  235. name: "IX_Preferences_Preference_Preferences_Id",
  236. schema: "jellyfin",
  237. table: "Preferences",
  238. column: "Preference_Preferences_Id");
  239. migrationBuilder.CreateIndex(
  240. name: "IX_ProviderMapping_ProviderMapping_ProviderMappings_Id",
  241. schema: "jellyfin",
  242. table: "ProviderMapping",
  243. column: "ProviderMapping_ProviderMappings_Id");
  244. migrationBuilder.CreateIndex(
  245. name: "IX_Users_ProfileImageId",
  246. schema: "jellyfin",
  247. table: "Users",
  248. column: "ProfileImageId");
  249. }
  250. protected override void Down(MigrationBuilder migrationBuilder)
  251. {
  252. migrationBuilder.DropTable(
  253. name: "AccessSchedule",
  254. schema: "jellyfin");
  255. migrationBuilder.DropTable(
  256. name: "Permissions",
  257. schema: "jellyfin");
  258. migrationBuilder.DropTable(
  259. name: "Preferences",
  260. schema: "jellyfin");
  261. migrationBuilder.DropTable(
  262. name: "ProviderMapping",
  263. schema: "jellyfin");
  264. migrationBuilder.DropTable(
  265. name: "Groups",
  266. schema: "jellyfin");
  267. migrationBuilder.DropTable(
  268. name: "Users",
  269. schema: "jellyfin");
  270. migrationBuilder.DropTable(
  271. name: "ImageInfo",
  272. schema: "jellyfin");
  273. }
  274. }
  275. }