From 46a0a2a6011bbeaf92af45f9478dda8608ab2c6a Mon Sep 17 00:00:00 2001 From: Patrick Barron Date: Tue, 26 May 2020 21:20:55 -0400 Subject: [PATCH] Update migrations and fix a few bugs --- Jellyfin.Data/Entities/AccessSchedule.cs | 4 +++- ...esigner.cs => 20200527010628_AddUsers.Designer.cs} | 11 +++++++---- ...7002411_AddUsers.cs => 20200527010628_AddUsers.cs} | 3 ++- .../Migrations/JellyfinDbModelSnapshot.cs | 8 ++++++-- Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs | 3 ++- 5 files changed, 20 insertions(+), 9 deletions(-) rename Jellyfin.Server.Implementations/Migrations/{20200517002411_AddUsers.Designer.cs => 20200527010628_AddUsers.Designer.cs} (97%) rename Jellyfin.Server.Implementations/Migrations/{20200517002411_AddUsers.cs => 20200527010628_AddUsers.cs} (98%) diff --git a/Jellyfin.Data/Entities/AccessSchedule.cs b/Jellyfin.Data/Entities/AccessSchedule.cs index 4248a34c9c..15c4e4cded 100644 --- a/Jellyfin.Data/Entities/AccessSchedule.cs +++ b/Jellyfin.Data/Entities/AccessSchedule.cs @@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; +using System.Xml.Serialization; using Jellyfin.Data.Enums; namespace Jellyfin.Data.Entities @@ -40,7 +41,7 @@ namespace Jellyfin.Data.Entities /// /// Identity, Indexed, Required. /// - [JsonIgnore] + [XmlIgnore] [Key] [Required] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] @@ -49,6 +50,7 @@ namespace Jellyfin.Data.Entities /// /// Gets or sets the id of the associated user. /// + [XmlIgnore] [Required] [ForeignKey("Id")] public Guid UserId { get; protected set; } diff --git a/Jellyfin.Server.Implementations/Migrations/20200517002411_AddUsers.Designer.cs b/Jellyfin.Server.Implementations/Migrations/20200527010628_AddUsers.Designer.cs similarity index 97% rename from Jellyfin.Server.Implementations/Migrations/20200517002411_AddUsers.Designer.cs rename to Jellyfin.Server.Implementations/Migrations/20200527010628_AddUsers.Designer.cs index 36c58c8ca2..e0321dfa78 100644 --- a/Jellyfin.Server.Implementations/Migrations/20200517002411_AddUsers.Designer.cs +++ b/Jellyfin.Server.Implementations/Migrations/20200527010628_AddUsers.Designer.cs @@ -1,5 +1,4 @@ #pragma warning disable CS1591 -#pragma warning disable SA1601 // using System; @@ -12,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Jellyfin.Server.Implementations.Migrations { [DbContext(typeof(JellyfinDb))] - [Migration("20200517002411_AddUsers")] + [Migration("20200527010628_AddUsers")] partial class AddUsers { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -20,7 +19,7 @@ namespace Jellyfin.Server.Implementations.Migrations #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("jellyfin") - .HasAnnotation("ProductVersion", "3.1.3"); + .HasAnnotation("ProductVersion", "3.1.4"); modelBuilder.Entity("Jellyfin.Data.Entities.AccessSchedule", b => { @@ -129,7 +128,8 @@ namespace Jellyfin.Server.Implementations.Migrations b.Property("Path") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasMaxLength(512); b.HasKey("Id"); @@ -331,6 +331,9 @@ namespace Jellyfin.Server.Implementations.Migrations b.Property("SubtitleMode") .HasColumnType("INTEGER"); + b.Property("SyncPlayAccess") + .HasColumnType("INTEGER"); + b.Property("Username") .IsRequired() .HasColumnType("TEXT") diff --git a/Jellyfin.Server.Implementations/Migrations/20200517002411_AddUsers.cs b/Jellyfin.Server.Implementations/Migrations/20200527010628_AddUsers.cs similarity index 98% rename from Jellyfin.Server.Implementations/Migrations/20200517002411_AddUsers.cs rename to Jellyfin.Server.Implementations/Migrations/20200527010628_AddUsers.cs index 55c6f371c0..0157e668d4 100644 --- a/Jellyfin.Server.Implementations/Migrations/20200517002411_AddUsers.cs +++ b/Jellyfin.Server.Implementations/Migrations/20200527010628_AddUsers.cs @@ -17,7 +17,7 @@ namespace Jellyfin.Server.Implementations.Migrations { Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), - Path = table.Column(nullable: false), + Path = table.Column(maxLength: 512, nullable: false), LastModified = table.Column(nullable: false) }, constraints: table => @@ -58,6 +58,7 @@ namespace Jellyfin.Server.Implementations.Migrations RemoteClientBitrateLimit = table.Column(nullable: true), InternalId = table.Column(nullable: false), ProfileImageId = table.Column(nullable: true), + SyncPlayAccess = table.Column(nullable: false), RowVersion = table.Column(nullable: false) }, constraints: table => diff --git a/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs b/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs index 46714e8659..0494744c79 100644 --- a/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs +++ b/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs @@ -15,7 +15,7 @@ namespace Jellyfin.Server.Implementations.Migrations #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("jellyfin") - .HasAnnotation("ProductVersion", "3.1.3"); + .HasAnnotation("ProductVersion", "3.1.4"); modelBuilder.Entity("Jellyfin.Data.Entities.AccessSchedule", b => { @@ -124,7 +124,8 @@ namespace Jellyfin.Server.Implementations.Migrations b.Property("Path") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("TEXT") + .HasMaxLength(512); b.HasKey("Id"); @@ -326,6 +327,9 @@ namespace Jellyfin.Server.Implementations.Migrations b.Property("SubtitleMode") .HasColumnType("INTEGER"); + b.Property("SyncPlayAccess") + .HasColumnType("INTEGER"); + b.Property("Username") .IsRequired() .HasColumnType("TEXT") diff --git a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs index af74d3a1d3..0113b49fd0 100644 --- a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs +++ b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs @@ -6,6 +6,7 @@ using Jellyfin.Data.Entities; using Jellyfin.Data.Enums; using Jellyfin.Server.Implementations; using Jellyfin.Server.Implementations.Users; +using MediaBrowser.Common.Json; using MediaBrowser.Controller; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Configuration; @@ -70,7 +71,7 @@ namespace Jellyfin.Server.Migrations.Routines foreach (var entry in queryResult) { - UserMockup mockup = JsonSerializer.Deserialize(entry[2].ToBlob()); + UserMockup mockup = JsonSerializer.Deserialize(entry[2].ToBlob(), JsonDefaults.GetOptions()); var userDataDir = Path.Combine(_paths.UserConfigurationDirectoryPath, mockup.Name); var config = File.Exists(Path.Combine(userDataDir, "config.xml"))