diff --git a/Jellyfin.Data/Entities/ProviderMapping.cs b/Jellyfin.Data/Entities/ProviderMapping.cs index 6197bd97b..e479341ad 100644 --- a/Jellyfin.Data/Entities/ProviderMapping.cs +++ b/Jellyfin.Data/Entities/ProviderMapping.cs @@ -43,12 +43,6 @@ namespace Jellyfin.Data.Entities if (string.IsNullOrEmpty(providerdata)) throw new ArgumentNullException(nameof(providerdata)); this.ProviderData = providerdata; - if (_user0 == null) throw new ArgumentNullException(nameof(_user0)); - _user0.ProviderMappings.Add(this); - - if (_group1 == null) throw new ArgumentNullException(nameof(_group1)); - _group1.ProviderMappings.Add(this); - Init(); } diff --git a/Jellyfin.Data/Entities/User.cs b/Jellyfin.Data/Entities/User.cs index a6221a249..f09b36bde 100644 --- a/Jellyfin.Data/Entities/User.cs +++ b/Jellyfin.Data/Entities/User.cs @@ -47,11 +47,11 @@ namespace Jellyfin.Data.Entities AuthenticationProviderId = authenticationProviderId; PasswordResetProviderId = passwordResetProviderId; - Groups = new HashSet(); - Permissions = new HashSet(); - ProviderMappings = new HashSet(); - Preferences = new HashSet(); AccessSchedules = new HashSet(); + // Groups = new HashSet(); + Permissions = new HashSet(); + Preferences = new HashSet(); + // ProviderMappings = new HashSet(); // Set default values Id = Guid.NewGuid(); @@ -342,11 +342,18 @@ namespace Jellyfin.Data.Entities * Navigation properties *************************************************************************/ + /// + /// Gets or sets the list of access schedules this user has. + /// + public virtual ICollection AccessSchedules { get; protected set; } + + /* /// /// Gets or sets the list of groups this user is a member of. /// [ForeignKey("Group_Groups_Guid")] public virtual ICollection Groups { get; protected set; } + */ /// /// Gets or sets the list of permissions this user has. @@ -354,11 +361,13 @@ namespace Jellyfin.Data.Entities [ForeignKey("Permission_Permissions_Guid")] public virtual ICollection Permissions { get; protected set; } + /* /// /// Gets or sets the list of provider mappings this user has. /// [ForeignKey("ProviderMapping_ProviderMappings_Id")] public virtual ICollection ProviderMappings { get; protected set; } + */ /// /// Gets or sets the list of preferences this user has. @@ -366,11 +375,6 @@ namespace Jellyfin.Data.Entities [ForeignKey("Preference_Preferences_Guid")] public virtual ICollection Preferences { get; protected set; } - /// - /// Gets or sets the list of access schedules this user has. - /// - public virtual ICollection AccessSchedules { get; protected set; } - /// /// Static create function (for use in LINQ queries, etc.) /// diff --git a/Jellyfin.Server.Implementations/JellyfinDb.cs b/Jellyfin.Server.Implementations/JellyfinDb.cs index 89fd371f8..ae783efd8 100644 --- a/Jellyfin.Server.Implementations/JellyfinDb.cs +++ b/Jellyfin.Server.Implementations/JellyfinDb.cs @@ -25,8 +25,6 @@ namespace Jellyfin.Server.Implementations public virtual DbSet ActivityLogs { get; set; } - public virtual DbSet Groups { get; set; } - public virtual DbSet Permissions { get; set; } public virtual DbSet Preferences { get; set; } @@ -45,6 +43,7 @@ namespace Jellyfin.Server.Implementations public virtual DbSet Episodes { get; set; } public virtual DbSet EpisodeMetadata { get; set; } public virtual DbSet Genres { get; set; } + public virtual DbSet Groups { get; set; } public virtual DbSet Libraries { get; set; } public virtual DbSet LibraryItems { get; set; } public virtual DbSet LibraryRoot { get; set; } diff --git a/Jellyfin.Server.Implementations/Migrations/20200529171409_AddUsers.Designer.cs b/Jellyfin.Server.Implementations/Migrations/20200531020729_AddUsers.Designer.cs similarity index 74% rename from Jellyfin.Server.Implementations/Migrations/20200529171409_AddUsers.Designer.cs rename to Jellyfin.Server.Implementations/Migrations/20200531020729_AddUsers.Designer.cs index d1d26726e..04fb9132d 100644 --- a/Jellyfin.Server.Implementations/Migrations/20200529171409_AddUsers.Designer.cs +++ b/Jellyfin.Server.Implementations/Migrations/20200531020729_AddUsers.Designer.cs @@ -1,4 +1,5 @@ #pragma warning disable CS1591 +#pragma warning disable SA1601 // using System; @@ -11,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Jellyfin.Server.Implementations.Migrations { [DbContext(typeof(JellyfinDb))] - [Migration("20200529171409_AddUsers")] + [Migration("20200531020729_AddUsers")] partial class AddUsers { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -92,31 +93,6 @@ namespace Jellyfin.Server.Implementations.Migrations b.ToTable("ActivityLogs"); }); - modelBuilder.Entity("Jellyfin.Data.Entities.Group", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("Group_Groups_Guid") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT") - .HasMaxLength(255); - - b.Property("RowVersion") - .IsConcurrencyToken() - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("Group_Groups_Guid"); - - b.ToTable("Groups"); - }); - modelBuilder.Entity("Jellyfin.Data.Entities.ImageInfo", b => { b.Property("Id") @@ -145,9 +121,6 @@ namespace Jellyfin.Server.Implementations.Migrations b.Property("Kind") .HasColumnType("INTEGER"); - b.Property("Permission_GroupPermissions_Id") - .HasColumnType("TEXT"); - b.Property("Permission_Permissions_Guid") .HasColumnType("TEXT"); @@ -160,8 +133,6 @@ namespace Jellyfin.Server.Implementations.Migrations b.HasKey("Id"); - b.HasIndex("Permission_GroupPermissions_Id"); - b.HasIndex("Permission_Permissions_Guid"); b.ToTable("Permissions"); @@ -179,9 +150,6 @@ namespace Jellyfin.Server.Implementations.Migrations b.Property("Preference_Preferences_Guid") .HasColumnType("TEXT"); - b.Property("Preference_Preferences_Id") - .HasColumnType("TEXT"); - b.Property("RowVersion") .IsConcurrencyToken() .HasColumnType("INTEGER"); @@ -195,46 +163,9 @@ namespace Jellyfin.Server.Implementations.Migrations b.HasIndex("Preference_Preferences_Guid"); - b.HasIndex("Preference_Preferences_Id"); - b.ToTable("Preferences"); }); - modelBuilder.Entity("Jellyfin.Data.Entities.ProviderMapping", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ProviderData") - .IsRequired() - .HasColumnType("TEXT") - .HasMaxLength(65535); - - b.Property("ProviderMapping_ProviderMappings_Id") - .HasColumnType("TEXT"); - - b.Property("ProviderName") - .IsRequired() - .HasColumnType("TEXT") - .HasMaxLength(255); - - b.Property("ProviderSecrets") - .IsRequired() - .HasColumnType("TEXT") - .HasMaxLength(65535); - - b.Property("RowVersion") - .IsConcurrencyToken() - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("ProviderMapping_ProviderMappings_Id"); - - b.ToTable("ProviderMapping"); - }); - modelBuilder.Entity("Jellyfin.Data.Entities.User", b => { b.Property("Id") @@ -355,19 +286,8 @@ namespace Jellyfin.Server.Implementations.Migrations .IsRequired(); }); - modelBuilder.Entity("Jellyfin.Data.Entities.Group", b => - { - b.HasOne("Jellyfin.Data.Entities.User", null) - .WithMany("Groups") - .HasForeignKey("Group_Groups_Guid"); - }); - modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b => { - b.HasOne("Jellyfin.Data.Entities.Group", null) - .WithMany("Permissions") - .HasForeignKey("Permission_GroupPermissions_Id"); - b.HasOne("Jellyfin.Data.Entities.User", null) .WithMany("Permissions") .HasForeignKey("Permission_Permissions_Guid"); @@ -378,21 +298,6 @@ namespace Jellyfin.Server.Implementations.Migrations b.HasOne("Jellyfin.Data.Entities.User", null) .WithMany("Preferences") .HasForeignKey("Preference_Preferences_Guid"); - - b.HasOne("Jellyfin.Data.Entities.Group", null) - .WithMany("Preferences") - .HasForeignKey("Preference_Preferences_Id"); - }); - - modelBuilder.Entity("Jellyfin.Data.Entities.ProviderMapping", b => - { - b.HasOne("Jellyfin.Data.Entities.Group", null) - .WithMany("ProviderMappings") - .HasForeignKey("ProviderMapping_ProviderMappings_Id"); - - b.HasOne("Jellyfin.Data.Entities.User", null) - .WithMany("ProviderMappings") - .HasForeignKey("ProviderMapping_ProviderMappings_Id"); }); modelBuilder.Entity("Jellyfin.Data.Entities.User", b => diff --git a/Jellyfin.Server.Implementations/Migrations/20200529171409_AddUsers.cs b/Jellyfin.Server.Implementations/Migrations/20200531020729_AddUsers.cs similarity index 64% rename from Jellyfin.Server.Implementations/Migrations/20200529171409_AddUsers.cs rename to Jellyfin.Server.Implementations/Migrations/20200531020729_AddUsers.cs index 2b84cf7b0..ec6b374ec 100644 --- a/Jellyfin.Server.Implementations/Migrations/20200529171409_AddUsers.cs +++ b/Jellyfin.Server.Implementations/Migrations/20200531020729_AddUsers.cs @@ -97,28 +97,6 @@ namespace Jellyfin.Server.Implementations.Migrations onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "Groups", - schema: "jellyfin", - columns: table => new - { - Id = table.Column(nullable: false), - Name = table.Column(maxLength: 255, nullable: false), - RowVersion = table.Column(nullable: false), - Group_Groups_Guid = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Groups", x => x.Id); - table.ForeignKey( - name: "FK_Groups_Users_Group_Groups_Guid", - column: x => x.Group_Groups_Guid, - principalSchema: "jellyfin", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - migrationBuilder.CreateTable( name: "Permissions", schema: "jellyfin", @@ -129,19 +107,11 @@ namespace Jellyfin.Server.Implementations.Migrations Kind = table.Column(nullable: false), Value = table.Column(nullable: false), RowVersion = table.Column(nullable: false), - Permission_GroupPermissions_Id = table.Column(nullable: true), Permission_Permissions_Guid = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Permissions", x => x.Id); - table.ForeignKey( - name: "FK_Permissions_Groups_Permission_GroupPermissions_Id", - column: x => x.Permission_GroupPermissions_Id, - principalSchema: "jellyfin", - principalTable: "Groups", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Permissions_Users_Permission_Permissions_Guid", column: x => x.Permission_Permissions_Guid, @@ -161,8 +131,7 @@ namespace Jellyfin.Server.Implementations.Migrations Kind = table.Column(nullable: false), Value = table.Column(maxLength: 65535, nullable: false), RowVersion = table.Column(nullable: false), - Preference_Preferences_Guid = table.Column(nullable: true), - Preference_Preferences_Id = table.Column(nullable: true) + Preference_Preferences_Guid = table.Column(nullable: true) }, constraints: table => { @@ -174,45 +143,6 @@ namespace Jellyfin.Server.Implementations.Migrations principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_Preferences_Groups_Preference_Preferences_Id", - column: x => x.Preference_Preferences_Id, - principalSchema: "jellyfin", - principalTable: "Groups", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "ProviderMapping", - schema: "jellyfin", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - ProviderName = table.Column(maxLength: 255, nullable: false), - ProviderSecrets = table.Column(maxLength: 65535, nullable: false), - ProviderData = table.Column(maxLength: 65535, nullable: false), - RowVersion = table.Column(nullable: false), - ProviderMapping_ProviderMappings_Id = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ProviderMapping", x => x.Id); - table.ForeignKey( - name: "FK_ProviderMapping_Groups_ProviderMapping_ProviderMappings_Id", - column: x => x.ProviderMapping_ProviderMappings_Id, - principalSchema: "jellyfin", - principalTable: "Groups", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_ProviderMapping_Users_ProviderMapping_ProviderMappings_Id", - column: x => x.ProviderMapping_ProviderMappings_Id, - principalSchema: "jellyfin", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( @@ -221,18 +151,6 @@ namespace Jellyfin.Server.Implementations.Migrations table: "AccessSchedule", column: "UserId"); - migrationBuilder.CreateIndex( - name: "IX_Groups_Group_Groups_Guid", - schema: "jellyfin", - table: "Groups", - column: "Group_Groups_Guid"); - - migrationBuilder.CreateIndex( - name: "IX_Permissions_Permission_GroupPermissions_Id", - schema: "jellyfin", - table: "Permissions", - column: "Permission_GroupPermissions_Id"); - migrationBuilder.CreateIndex( name: "IX_Permissions_Permission_Permissions_Guid", schema: "jellyfin", @@ -245,18 +163,6 @@ namespace Jellyfin.Server.Implementations.Migrations table: "Preferences", column: "Preference_Preferences_Guid"); - migrationBuilder.CreateIndex( - name: "IX_Preferences_Preference_Preferences_Id", - schema: "jellyfin", - table: "Preferences", - column: "Preference_Preferences_Id"); - - migrationBuilder.CreateIndex( - name: "IX_ProviderMapping_ProviderMapping_ProviderMappings_Id", - schema: "jellyfin", - table: "ProviderMapping", - column: "ProviderMapping_ProviderMappings_Id"); - migrationBuilder.CreateIndex( name: "IX_Users_ProfileImageId", schema: "jellyfin", @@ -278,14 +184,6 @@ namespace Jellyfin.Server.Implementations.Migrations name: "Preferences", schema: "jellyfin"); - migrationBuilder.DropTable( - name: "ProviderMapping", - schema: "jellyfin"); - - migrationBuilder.DropTable( - name: "Groups", - schema: "jellyfin"); - migrationBuilder.DropTable( name: "Users", schema: "jellyfin"); diff --git a/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs b/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs index 9a2315802..115c98aa3 100644 --- a/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs +++ b/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs @@ -88,31 +88,6 @@ namespace Jellyfin.Server.Implementations.Migrations b.ToTable("ActivityLogs"); }); - modelBuilder.Entity("Jellyfin.Data.Entities.Group", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("Group_Groups_Guid") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT") - .HasMaxLength(255); - - b.Property("RowVersion") - .IsConcurrencyToken() - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("Group_Groups_Guid"); - - b.ToTable("Groups"); - }); - modelBuilder.Entity("Jellyfin.Data.Entities.ImageInfo", b => { b.Property("Id") @@ -141,9 +116,6 @@ namespace Jellyfin.Server.Implementations.Migrations b.Property("Kind") .HasColumnType("INTEGER"); - b.Property("Permission_GroupPermissions_Id") - .HasColumnType("TEXT"); - b.Property("Permission_Permissions_Guid") .HasColumnType("TEXT"); @@ -156,8 +128,6 @@ namespace Jellyfin.Server.Implementations.Migrations b.HasKey("Id"); - b.HasIndex("Permission_GroupPermissions_Id"); - b.HasIndex("Permission_Permissions_Guid"); b.ToTable("Permissions"); @@ -175,9 +145,6 @@ namespace Jellyfin.Server.Implementations.Migrations b.Property("Preference_Preferences_Guid") .HasColumnType("TEXT"); - b.Property("Preference_Preferences_Id") - .HasColumnType("TEXT"); - b.Property("RowVersion") .IsConcurrencyToken() .HasColumnType("INTEGER"); @@ -191,46 +158,9 @@ namespace Jellyfin.Server.Implementations.Migrations b.HasIndex("Preference_Preferences_Guid"); - b.HasIndex("Preference_Preferences_Id"); - b.ToTable("Preferences"); }); - modelBuilder.Entity("Jellyfin.Data.Entities.ProviderMapping", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ProviderData") - .IsRequired() - .HasColumnType("TEXT") - .HasMaxLength(65535); - - b.Property("ProviderMapping_ProviderMappings_Id") - .HasColumnType("TEXT"); - - b.Property("ProviderName") - .IsRequired() - .HasColumnType("TEXT") - .HasMaxLength(255); - - b.Property("ProviderSecrets") - .IsRequired() - .HasColumnType("TEXT") - .HasMaxLength(65535); - - b.Property("RowVersion") - .IsConcurrencyToken() - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("ProviderMapping_ProviderMappings_Id"); - - b.ToTable("ProviderMapping"); - }); - modelBuilder.Entity("Jellyfin.Data.Entities.User", b => { b.Property("Id") @@ -351,19 +281,8 @@ namespace Jellyfin.Server.Implementations.Migrations .IsRequired(); }); - modelBuilder.Entity("Jellyfin.Data.Entities.Group", b => - { - b.HasOne("Jellyfin.Data.Entities.User", null) - .WithMany("Groups") - .HasForeignKey("Group_Groups_Guid"); - }); - modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b => { - b.HasOne("Jellyfin.Data.Entities.Group", null) - .WithMany("Permissions") - .HasForeignKey("Permission_GroupPermissions_Id"); - b.HasOne("Jellyfin.Data.Entities.User", null) .WithMany("Permissions") .HasForeignKey("Permission_Permissions_Guid"); @@ -374,21 +293,6 @@ namespace Jellyfin.Server.Implementations.Migrations b.HasOne("Jellyfin.Data.Entities.User", null) .WithMany("Preferences") .HasForeignKey("Preference_Preferences_Guid"); - - b.HasOne("Jellyfin.Data.Entities.Group", null) - .WithMany("Preferences") - .HasForeignKey("Preference_Preferences_Id"); - }); - - modelBuilder.Entity("Jellyfin.Data.Entities.ProviderMapping", b => - { - b.HasOne("Jellyfin.Data.Entities.Group", null) - .WithMany("ProviderMappings") - .HasForeignKey("ProviderMapping_ProviderMappings_Id"); - - b.HasOne("Jellyfin.Data.Entities.User", null) - .WithMany("ProviderMappings") - .HasForeignKey("ProviderMapping_ProviderMappings_Id"); }); modelBuilder.Entity("Jellyfin.Data.Entities.User", b =>