20200613155524_AddUsers.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. namespace Jellyfin.Server.Implementations.Migrations
  4. {
  5. public partial class AddUsers : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "ImageInfos",
  11. schema: "jellyfin",
  12. columns: table => new
  13. {
  14. Id = table.Column<int>(nullable: false)
  15. .Annotation("Sqlite:Autoincrement", true),
  16. Path = table.Column<string>(maxLength: 512, nullable: false),
  17. LastModified = table.Column<DateTime>(nullable: false)
  18. },
  19. constraints: table =>
  20. {
  21. table.PrimaryKey("PK_ImageInfos", x => x.Id);
  22. });
  23. migrationBuilder.CreateTable(
  24. name: "Users",
  25. schema: "jellyfin",
  26. columns: table => new
  27. {
  28. Id = table.Column<Guid>(nullable: false),
  29. Username = table.Column<string>(maxLength: 255, nullable: false),
  30. Password = table.Column<string>(maxLength: 65535, nullable: true),
  31. EasyPassword = table.Column<string>(maxLength: 65535, nullable: true),
  32. MustUpdatePassword = table.Column<bool>(nullable: false),
  33. AudioLanguagePreference = table.Column<string>(maxLength: 255, nullable: true),
  34. AuthenticationProviderId = table.Column<string>(maxLength: 255, nullable: false),
  35. PasswordResetProviderId = table.Column<string>(maxLength: 255, nullable: false),
  36. InvalidLoginAttemptCount = table.Column<int>(nullable: false),
  37. LastActivityDate = table.Column<DateTime>(nullable: true),
  38. LastLoginDate = table.Column<DateTime>(nullable: true),
  39. LoginAttemptsBeforeLockout = table.Column<int>(nullable: true),
  40. SubtitleMode = table.Column<int>(nullable: false),
  41. PlayDefaultAudioTrack = table.Column<bool>(nullable: false),
  42. SubtitleLanguagePreference = table.Column<string>(maxLength: 255, nullable: true),
  43. DisplayMissingEpisodes = table.Column<bool>(nullable: false),
  44. DisplayCollectionsView = table.Column<bool>(nullable: false),
  45. EnableLocalPassword = table.Column<bool>(nullable: false),
  46. HidePlayedInLatest = table.Column<bool>(nullable: false),
  47. RememberAudioSelections = table.Column<bool>(nullable: false),
  48. RememberSubtitleSelections = table.Column<bool>(nullable: false),
  49. EnableNextEpisodeAutoPlay = table.Column<bool>(nullable: false),
  50. EnableAutoLogin = table.Column<bool>(nullable: false),
  51. EnableUserPreferenceAccess = table.Column<bool>(nullable: false),
  52. MaxParentalAgeRating = table.Column<int>(nullable: true),
  53. RemoteClientBitrateLimit = table.Column<int>(nullable: true),
  54. InternalId = table.Column<long>(nullable: false),
  55. ProfileImageId = table.Column<int>(nullable: true),
  56. SyncPlayAccess = table.Column<int>(nullable: false),
  57. RowVersion = table.Column<uint>(nullable: false)
  58. },
  59. constraints: table =>
  60. {
  61. table.PrimaryKey("PK_Users", x => x.Id);
  62. table.ForeignKey(
  63. name: "FK_Users_ImageInfos_ProfileImageId",
  64. column: x => x.ProfileImageId,
  65. principalSchema: "jellyfin",
  66. principalTable: "ImageInfos",
  67. principalColumn: "Id",
  68. onDelete: ReferentialAction.Restrict);
  69. });
  70. migrationBuilder.CreateTable(
  71. name: "AccessSchedules",
  72. schema: "jellyfin",
  73. columns: table => new
  74. {
  75. Id = table.Column<int>(nullable: false)
  76. .Annotation("Sqlite:Autoincrement", true),
  77. UserId = table.Column<Guid>(nullable: false),
  78. DayOfWeek = table.Column<int>(nullable: false),
  79. StartHour = table.Column<double>(nullable: false),
  80. EndHour = table.Column<double>(nullable: false)
  81. },
  82. constraints: table =>
  83. {
  84. table.PrimaryKey("PK_AccessSchedules", x => x.Id);
  85. table.ForeignKey(
  86. name: "FK_AccessSchedules_Users_UserId",
  87. column: x => x.UserId,
  88. principalSchema: "jellyfin",
  89. principalTable: "Users",
  90. principalColumn: "Id",
  91. onDelete: ReferentialAction.Cascade);
  92. });
  93. migrationBuilder.CreateTable(
  94. name: "Permissions",
  95. schema: "jellyfin",
  96. columns: table => new
  97. {
  98. Id = table.Column<int>(nullable: false)
  99. .Annotation("Sqlite:Autoincrement", true),
  100. Kind = table.Column<int>(nullable: false),
  101. Value = table.Column<bool>(nullable: false),
  102. RowVersion = table.Column<uint>(nullable: false),
  103. Permission_Permissions_Guid = table.Column<Guid>(nullable: true)
  104. },
  105. constraints: table =>
  106. {
  107. table.PrimaryKey("PK_Permissions", x => x.Id);
  108. table.ForeignKey(
  109. name: "FK_Permissions_Users_Permission_Permissions_Guid",
  110. column: x => x.Permission_Permissions_Guid,
  111. principalSchema: "jellyfin",
  112. principalTable: "Users",
  113. principalColumn: "Id",
  114. onDelete: ReferentialAction.Restrict);
  115. });
  116. migrationBuilder.CreateTable(
  117. name: "Preferences",
  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<string>(maxLength: 65535, nullable: false),
  125. RowVersion = table.Column<uint>(nullable: false),
  126. Preference_Preferences_Guid = table.Column<Guid>(nullable: true)
  127. },
  128. constraints: table =>
  129. {
  130. table.PrimaryKey("PK_Preferences", x => x.Id);
  131. table.ForeignKey(
  132. name: "FK_Preferences_Users_Preference_Preferences_Guid",
  133. column: x => x.Preference_Preferences_Guid,
  134. principalSchema: "jellyfin",
  135. principalTable: "Users",
  136. principalColumn: "Id",
  137. onDelete: ReferentialAction.Restrict);
  138. });
  139. migrationBuilder.CreateIndex(
  140. name: "IX_AccessSchedules_UserId",
  141. schema: "jellyfin",
  142. table: "AccessSchedules",
  143. column: "UserId");
  144. migrationBuilder.CreateIndex(
  145. name: "IX_Permissions_Permission_Permissions_Guid",
  146. schema: "jellyfin",
  147. table: "Permissions",
  148. column: "Permission_Permissions_Guid");
  149. migrationBuilder.CreateIndex(
  150. name: "IX_Preferences_Preference_Preferences_Guid",
  151. schema: "jellyfin",
  152. table: "Preferences",
  153. column: "Preference_Preferences_Guid");
  154. migrationBuilder.CreateIndex(
  155. name: "IX_Users_ProfileImageId",
  156. schema: "jellyfin",
  157. table: "Users",
  158. column: "ProfileImageId");
  159. }
  160. protected override void Down(MigrationBuilder migrationBuilder)
  161. {
  162. migrationBuilder.DropTable(
  163. name: "AccessSchedules",
  164. schema: "jellyfin");
  165. migrationBuilder.DropTable(
  166. name: "Permissions",
  167. schema: "jellyfin");
  168. migrationBuilder.DropTable(
  169. name: "Preferences",
  170. schema: "jellyfin");
  171. migrationBuilder.DropTable(
  172. name: "Users",
  173. schema: "jellyfin");
  174. migrationBuilder.DropTable(
  175. name: "ImageInfos",
  176. schema: "jellyfin");
  177. }
  178. }
  179. }