diff --git a/Kyoo.Common/Models/Resources/Season.cs b/Kyoo.Common/Models/Resources/Season.cs index 2bd62a6a..761fa2af 100644 --- a/Kyoo.Common/Models/Resources/Season.cs +++ b/Kyoo.Common/Models/Resources/Season.cs @@ -15,7 +15,7 @@ namespace Kyoo.Models public string Overview { get; set; } public int? Year { get; set; } - [JsonIgnore] public string ImgPrimary { get; set; } + [JsonIgnore] public string Poster { get; set; } public virtual IEnumerable ExternalIDs { get; set; } [JsonIgnore] public virtual Show Show { get; set; } @@ -28,7 +28,7 @@ namespace Kyoo.Models string title, string overview, int? year, - string imgPrimary, + string poster, IEnumerable externalIDs) { ShowID = showID; @@ -36,7 +36,7 @@ namespace Kyoo.Models Title = title; Overview = overview; Year = year; - ImgPrimary = imgPrimary; + Poster = poster; ExternalIDs = externalIDs; } } diff --git a/Kyoo/Controllers/ThumbnailsManager.cs b/Kyoo/Controllers/ThumbnailsManager.cs index 04520d04..23b75846 100644 --- a/Kyoo/Controllers/ThumbnailsManager.cs +++ b/Kyoo/Controllers/ThumbnailsManager.cs @@ -82,11 +82,11 @@ namespace Kyoo.Controllers if (season?.Show?.Path == null) return default; - if (season.ImgPrimary != null) + if (season.Poster != null) { string localPath = Path.Combine(season.Show.Path, $"season-{season.SeasonNumber}.jpg"); if (alwaysDownload || !File.Exists(localPath)) - await DownloadImage(season.ImgPrimary, localPath, $"The poster of {season.Show.Title}'s season {season.SeasonNumber}"); + await DownloadImage(season.Poster, localPath, $"The poster of {season.Show.Title}'s season {season.SeasonNumber}"); } return season; } diff --git a/Kyoo/Models/DatabaseContext.cs b/Kyoo/Models/DatabaseContext.cs index 90435111..9cd8274d 100644 --- a/Kyoo/Models/DatabaseContext.cs +++ b/Kyoo/Models/DatabaseContext.cs @@ -55,17 +55,21 @@ namespace Kyoo modelBuilder.HasPostgresEnum(); modelBuilder.HasPostgresEnum(); - modelBuilder.Entity() + modelBuilder.Ignore(); + modelBuilder.Ignore(); + modelBuilder.Ignore(); + modelBuilder.Ignore(); + + modelBuilder.Entity() .Property(x => x.Paths) .HasColumnType("text[]") .Metadata.SetValueComparer(_stringArrayComparer); - modelBuilder.Entity() + modelBuilder.Entity() .Property(x => x.Aliases) .HasColumnType("text[]") .Metadata.SetValueComparer(_stringArrayComparer); - - + modelBuilder.Entity() .Property(t => t.IsDefault) .ValueGeneratedNever(); @@ -77,16 +81,16 @@ namespace Kyoo modelBuilder.Entity() .HasKey(x => new {x.ShowID, x.GenreID}); - modelBuilder.Entity() + modelBuilder.Entity() .Ignore(x => x.Shows) .Ignore(x => x.Collections) .Ignore(x => x.Providers); - modelBuilder.Entity() + modelBuilder.Entity() .Ignore(x => x.Shows) .Ignore(x => x.Libraries); - modelBuilder.Entity() + modelBuilder.Entity() .Ignore(x => x.Genres) .Ignore(x => x.Libraries) .Ignore(x => x.Collections); @@ -97,12 +101,52 @@ namespace Kyoo .Ignore(x => x.Poster) .Ignore(x => x.ExternalIDs); - modelBuilder.Entity() + modelBuilder.Entity() .Ignore(x => x.Shows); - + + modelBuilder.Entity() + .HasOne(x => x.Library as LibraryDE) + .WithMany(x => x.Links); + modelBuilder.Entity() + .HasOne(x => x.Show as ShowDE) + .WithMany(x => x.LibraryLinks); + modelBuilder.Entity() + .HasOne(x => x.Collection as CollectionDE) + .WithMany(x => x.LibraryLinks); + + modelBuilder.Entity() + .HasOne(x => x.Collection as CollectionDE) + .WithMany(x => x.Links); + modelBuilder.Entity() + .HasOne(x => x.Show as ShowDE) + .WithMany(x => x.CollectionLinks); + + modelBuilder.Entity() + .HasOne(x => x.Genre as GenreDE) + .WithMany(x => x.Links); + modelBuilder.Entity() + .HasOne(x => x.Show as ShowDE) + .WithMany(x => x.GenreLinks); + + modelBuilder.Entity() + .HasOne(x => x.Library as LibraryDE) + .WithMany(x => x.ProviderLinks); + + modelBuilder.Entity() + .HasOne(x => x.Show as ShowDE) + .WithMany(x => x.Seasons); + modelBuilder.Entity() + .HasOne(x => x.Show as ShowDE) + .WithMany(x => x.Episodes); + modelBuilder.Entity() + .HasOne(x => x.Show as ShowDE) + .WithMany(x => x.People); + + + modelBuilder.Entity() - .HasOne(x => x.Show) + .HasOne(x => x.Show as ShowDE) .WithMany(x => x.ExternalIDs) .OnDelete(DeleteBehavior.Cascade); modelBuilder.Entity() @@ -118,20 +162,27 @@ namespace Kyoo .WithMany(x => x.ExternalIDs) .OnDelete(DeleteBehavior.Cascade); + modelBuilder.Entity().Property(x => x.Slug).IsRequired(); + modelBuilder.Entity().Property(x => x.Slug).IsRequired(); + modelBuilder.Entity().Property(x => x.Slug).IsRequired(); + modelBuilder.Entity().Property(x => x.Slug).IsRequired(); + modelBuilder.Entity().Property(x => x.Slug).IsRequired(); + modelBuilder.Entity().Property(x => x.Slug).IsRequired(); + modelBuilder.Entity().Property(x => x.Slug).IsRequired(); - modelBuilder.Entity() + modelBuilder.Entity() .HasIndex(x => x.Slug) .IsUnique(); - modelBuilder.Entity() + modelBuilder.Entity() .HasIndex(x => x.Slug) .IsUnique(); - modelBuilder.Entity() + modelBuilder.Entity() .HasIndex(x => x.Slug) .IsUnique(); modelBuilder.Entity() .HasIndex(x => x.Slug) .IsUnique(); - modelBuilder.Entity() + modelBuilder.Entity() .HasIndex(x => x.Slug) .IsUnique(); modelBuilder.Entity() diff --git a/Kyoo/Models/DatabaseMigrations/Internal/20200815231223_Initial.Designer.cs b/Kyoo/Models/DatabaseMigrations/Internal/20200816150752_Initial.Designer.cs similarity index 81% rename from Kyoo/Models/DatabaseMigrations/Internal/20200815231223_Initial.Designer.cs rename to Kyoo/Models/DatabaseMigrations/Internal/20200816150752_Initial.Designer.cs index 35a902db..a95792e6 100644 --- a/Kyoo/Models/DatabaseMigrations/Internal/20200815231223_Initial.Designer.cs +++ b/Kyoo/Models/DatabaseMigrations/Internal/20200816150752_Initial.Designer.cs @@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Kyoo.Models.DatabaseMigrations.Internal { [DbContext(typeof(DatabaseContext))] - [Migration("20200815231223_Initial")] + [Migration("20200816150752_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -25,17 +25,13 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasAnnotation("ProductVersion", "3.1.3") .HasAnnotation("Relational:MaxIdentifierLength", 63); - modelBuilder.Entity("Kyoo.Models.Collection", b => + modelBuilder.Entity("Kyoo.Models.CollectionDE", b => { b.Property("ID") .ValueGeneratedOnAdd() .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - b.Property("Name") .HasColumnType("text"); @@ -46,6 +42,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -53,9 +50,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.HasIndex("Slug") .IsUnique(); - b.ToTable("Collection"); + b.ToTable("Collections"); - b.HasDiscriminator("Discriminator").HasValue("Collection"); + b.HasDiscriminator(); }); modelBuilder.Entity("Kyoo.Models.CollectionLink", b => @@ -65,24 +62,14 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("CollectionDEID") - .HasColumnType("integer"); - b.Property("CollectionID") .HasColumnType("integer"); - b.Property("ShowDEID") - .HasColumnType("integer"); - b.Property("ShowID") .HasColumnType("integer"); b.HasKey("ID"); - b.HasIndex("CollectionDEID"); - - b.HasIndex("ShowDEID"); - b.HasIndex("ShowID"); b.HasIndex("CollectionID", "ShowID") @@ -141,21 +128,18 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.ToTable("Episodes"); }); - modelBuilder.Entity("Kyoo.Models.Genre", b => + modelBuilder.Entity("Kyoo.Models.GenreDE", b => { b.Property("ID") .ValueGeneratedOnAdd() .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - b.Property("Name") .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -163,9 +147,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.HasIndex("Slug") .IsUnique(); - b.ToTable("Genre"); + b.ToTable("Genres"); - b.HasDiscriminator("Discriminator").HasValue("Genre"); + b.HasDiscriminator(); }); modelBuilder.Entity("Kyoo.Models.GenreLink", b => @@ -176,34 +160,20 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.Property("GenreID") .HasColumnType("integer"); - b.Property("GenreDEID") - .HasColumnType("integer"); - - b.Property("ShowDEID") - .HasColumnType("integer"); - b.HasKey("ShowID", "GenreID"); - b.HasIndex("GenreDEID"); - b.HasIndex("GenreID"); - b.HasIndex("ShowDEID"); - b.ToTable("GenreLinks"); }); - modelBuilder.Entity("Kyoo.Models.Library", b => + modelBuilder.Entity("Kyoo.Models.LibraryDE", b => { b.Property("ID") .ValueGeneratedOnAdd() .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - b.Property("Name") .HasColumnType("text"); @@ -211,6 +181,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text[]"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -218,9 +189,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.HasIndex("Slug") .IsUnique(); - b.ToTable("Library"); + b.ToTable("Libraries"); - b.HasDiscriminator("Discriminator").HasValue("Library"); + b.HasDiscriminator(); }); modelBuilder.Entity("Kyoo.Models.LibraryLink", b => @@ -230,34 +201,19 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("CollectionDEID") - .HasColumnType("integer"); - b.Property("CollectionID") .HasColumnType("integer"); - b.Property("LibraryDEID") - .HasColumnType("integer"); - b.Property("LibraryID") .HasColumnType("integer"); - b.Property("ShowDEID") - .HasColumnType("integer"); - b.Property("ShowID") .HasColumnType("integer"); b.HasKey("ID"); - b.HasIndex("CollectionDEID"); - b.HasIndex("CollectionID"); - b.HasIndex("LibraryDEID"); - - b.HasIndex("ShowDEID"); - b.HasIndex("ShowID"); b.HasIndex("LibraryID", "CollectionID") @@ -326,6 +282,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -378,6 +335,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -395,9 +353,6 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("LibraryDEID") - .HasColumnType("integer"); - b.Property("LibraryID") .HasColumnType("integer"); @@ -406,8 +361,6 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.HasKey("ID"); - b.HasIndex("LibraryDEID"); - b.HasIndex("LibraryID"); b.HasIndex("ProviderID"); @@ -422,10 +375,10 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("ImgPrimary") + b.Property("Overview") .HasColumnType("text"); - b.Property("Overview") + b.Property("Poster") .HasColumnType("text"); b.Property("SeasonNumber") @@ -448,7 +401,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.ToTable("Seasons"); }); - modelBuilder.Entity("Kyoo.Models.Show", b => + modelBuilder.Entity("Kyoo.Models.ShowDE", b => { b.Property("ID") .ValueGeneratedOnAdd() @@ -461,10 +414,6 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.Property("Backdrop") .HasColumnType("text"); - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - b.Property("EndYear") .HasColumnType("integer"); @@ -484,6 +433,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.Property("StartYear") @@ -508,9 +458,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.HasIndex("StudioID"); - b.ToTable("Show"); + b.ToTable("Shows"); - b.HasDiscriminator("Discriminator").HasValue("Show"); + b.HasDiscriminator(); }); modelBuilder.Entity("Kyoo.Models.Studio", b => @@ -524,6 +474,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -575,50 +526,14 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.ToTable("Tracks"); }); - modelBuilder.Entity("Kyoo.Models.CollectionDE", b => - { - b.HasBaseType("Kyoo.Models.Collection"); - - b.HasDiscriminator().HasValue("CollectionDE"); - }); - - modelBuilder.Entity("Kyoo.Models.GenreDE", b => - { - b.HasBaseType("Kyoo.Models.Genre"); - - b.HasDiscriminator().HasValue("GenreDE"); - }); - - modelBuilder.Entity("Kyoo.Models.LibraryDE", b => - { - b.HasBaseType("Kyoo.Models.Library"); - - b.HasDiscriminator().HasValue("LibraryDE"); - }); - - modelBuilder.Entity("Kyoo.Models.ShowDE", b => - { - b.HasBaseType("Kyoo.Models.Show"); - - b.HasDiscriminator().HasValue("ShowDE"); - }); - modelBuilder.Entity("Kyoo.Models.CollectionLink", b => { - b.HasOne("Kyoo.Models.CollectionDE", null) + b.HasOne("Kyoo.Models.CollectionDE", "Collection") .WithMany("Links") - .HasForeignKey("CollectionDEID"); - - b.HasOne("Kyoo.Models.Collection", "Collection") - .WithMany() .HasForeignKey("CollectionID"); - b.HasOne("Kyoo.Models.ShowDE", null) + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("CollectionLinks") - .HasForeignKey("ShowDEID"); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany() .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -630,7 +545,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .WithMany("Episodes") .HasForeignKey("SeasonID"); - b.HasOne("Kyoo.Models.Show", "Show") + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("Episodes") .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade) @@ -639,22 +554,14 @@ namespace Kyoo.Models.DatabaseMigrations.Internal modelBuilder.Entity("Kyoo.Models.GenreLink", b => { - b.HasOne("Kyoo.Models.GenreDE", null) + b.HasOne("Kyoo.Models.GenreDE", "Genre") .WithMany("Links") - .HasForeignKey("GenreDEID"); - - b.HasOne("Kyoo.Models.Genre", "Genre") - .WithMany() .HasForeignKey("GenreID") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Kyoo.Models.ShowDE", null) + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("GenreLinks") - .HasForeignKey("ShowDEID"); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany() .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -662,30 +569,18 @@ namespace Kyoo.Models.DatabaseMigrations.Internal modelBuilder.Entity("Kyoo.Models.LibraryLink", b => { - b.HasOne("Kyoo.Models.CollectionDE", null) + b.HasOne("Kyoo.Models.CollectionDE", "Collection") .WithMany("LibraryLinks") - .HasForeignKey("CollectionDEID"); - - b.HasOne("Kyoo.Models.Collection", "Collection") - .WithMany() .HasForeignKey("CollectionID"); - b.HasOne("Kyoo.Models.LibraryDE", null) + b.HasOne("Kyoo.Models.LibraryDE", "Library") .WithMany("Links") - .HasForeignKey("LibraryDEID"); - - b.HasOne("Kyoo.Models.Library", "Library") - .WithMany() .HasForeignKey("LibraryID") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Kyoo.Models.ShowDE", null) + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("LibraryLinks") - .HasForeignKey("ShowDEID"); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany() .HasForeignKey("ShowID"); }); @@ -712,7 +607,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasForeignKey("SeasonID") .OnDelete(DeleteBehavior.Cascade); - b.HasOne("Kyoo.Models.Show", "Show") + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("ExternalIDs") .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade); @@ -726,7 +621,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Kyoo.Models.Show", "Show") + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("People") .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade) @@ -735,12 +630,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal modelBuilder.Entity("Kyoo.Models.ProviderLink", b => { - b.HasOne("Kyoo.Models.LibraryDE", null) + b.HasOne("Kyoo.Models.LibraryDE", "Library") .WithMany("ProviderLinks") - .HasForeignKey("LibraryDEID"); - - b.HasOne("Kyoo.Models.Library", "Library") - .WithMany() .HasForeignKey("LibraryID"); b.HasOne("Kyoo.Models.ProviderID", "Provider") @@ -752,17 +643,17 @@ namespace Kyoo.Models.DatabaseMigrations.Internal modelBuilder.Entity("Kyoo.Models.Season", b => { - b.HasOne("Kyoo.Models.Show", "Show") + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("Seasons") .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Kyoo.Models.Show", b => + modelBuilder.Entity("Kyoo.Models.ShowDE", b => { b.HasOne("Kyoo.Models.Studio", "Studio") - .WithMany("Shows") + .WithMany() .HasForeignKey("StudioID"); }); diff --git a/Kyoo/Models/DatabaseMigrations/Internal/20200815231223_Initial.cs b/Kyoo/Models/DatabaseMigrations/Internal/20200816150752_Initial.cs similarity index 75% rename from Kyoo/Models/DatabaseMigrations/Internal/20200815231223_Initial.cs rename to Kyoo/Models/DatabaseMigrations/Internal/20200816150752_Initial.cs index 79d4b9a4..4d6c2d55 100644 --- a/Kyoo/Models/DatabaseMigrations/Internal/20200815231223_Initial.cs +++ b/Kyoo/Models/DatabaseMigrations/Internal/20200816150752_Initial.cs @@ -14,51 +14,48 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .Annotation("Npgsql:Enum:stream_type", "unknow,video,audio,subtitle"); migrationBuilder.CreateTable( - name: "Collection", + name: "Collections", columns: table => new { ID = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Slug = table.Column(nullable: true), + Slug = table.Column(nullable: false), Name = table.Column(nullable: true), Poster = table.Column(nullable: true), - Overview = table.Column(nullable: true), - Discriminator = table.Column(nullable: false) + Overview = table.Column(nullable: true) }, constraints: table => { - table.PrimaryKey("PK_Collection", x => x.ID); + table.PrimaryKey("PK_Collections", x => x.ID); }); migrationBuilder.CreateTable( - name: "Genre", + name: "Genres", columns: table => new { ID = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Slug = table.Column(nullable: true), - Name = table.Column(nullable: true), - Discriminator = table.Column(nullable: false) + Slug = table.Column(nullable: false), + Name = table.Column(nullable: true) }, constraints: table => { - table.PrimaryKey("PK_Genre", x => x.ID); + table.PrimaryKey("PK_Genres", x => x.ID); }); migrationBuilder.CreateTable( - name: "Library", + name: "Libraries", columns: table => new { ID = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Slug = table.Column(nullable: true), + Slug = table.Column(nullable: false), Name = table.Column(nullable: true), - Paths = table.Column(type: "text[]", nullable: true), - Discriminator = table.Column(nullable: false) + Paths = table.Column(type: "text[]", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_Library", x => x.ID); + table.PrimaryKey("PK_Libraries", x => x.ID); }); migrationBuilder.CreateTable( @@ -67,7 +64,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal { ID = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Slug = table.Column(nullable: true), + Slug = table.Column(nullable: false), Name = table.Column(nullable: true), Poster = table.Column(nullable: true) }, @@ -82,7 +79,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal { ID = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Slug = table.Column(nullable: true), + Slug = table.Column(nullable: false), Name = table.Column(nullable: true), Logo = table.Column(nullable: true) }, @@ -97,7 +94,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal { ID = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Slug = table.Column(nullable: true), + Slug = table.Column(nullable: false), Name = table.Column(nullable: true) }, constraints: table => @@ -112,22 +109,15 @@ namespace Kyoo.Models.DatabaseMigrations.Internal ID = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProviderID = table.Column(nullable: false), - LibraryID = table.Column(nullable: true), - LibraryDEID = table.Column(nullable: true) + LibraryID = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_ProviderLinks", x => x.ID); table.ForeignKey( - name: "FK_ProviderLinks_Library_LibraryDEID", - column: x => x.LibraryDEID, - principalTable: "Library", - principalColumn: "ID", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_ProviderLinks_Library_LibraryID", + name: "FK_ProviderLinks_Libraries_LibraryID", column: x => x.LibraryID, - principalTable: "Library", + principalTable: "Libraries", principalColumn: "ID", onDelete: ReferentialAction.Restrict); table.ForeignKey( @@ -139,12 +129,12 @@ namespace Kyoo.Models.DatabaseMigrations.Internal }); migrationBuilder.CreateTable( - name: "Show", + name: "Shows", columns: table => new { ID = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Slug = table.Column(nullable: true), + Slug = table.Column(nullable: false), Title = table.Column(nullable: true), Aliases = table.Column(type: "text[]", nullable: true), Path = table.Column(nullable: true), @@ -157,14 +147,13 @@ namespace Kyoo.Models.DatabaseMigrations.Internal Logo = table.Column(nullable: true), Backdrop = table.Column(nullable: true), IsMovie = table.Column(nullable: false), - StudioID = table.Column(nullable: true), - Discriminator = table.Column(nullable: false) + StudioID = table.Column(nullable: true) }, constraints: table => { - table.PrimaryKey("PK_Show", x => x.ID); + table.PrimaryKey("PK_Shows", x => x.ID); table.ForeignKey( - name: "FK_Show_Studios_StudioID", + name: "FK_Shows_Studios_StudioID", column: x => x.StudioID, principalTable: "Studios", principalColumn: "ID", @@ -178,35 +167,21 @@ namespace Kyoo.Models.DatabaseMigrations.Internal ID = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CollectionID = table.Column(nullable: true), - ShowID = table.Column(nullable: false), - CollectionDEID = table.Column(nullable: true), - ShowDEID = table.Column(nullable: true) + ShowID = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_CollectionLinks", x => x.ID); table.ForeignKey( - name: "FK_CollectionLinks_Collection_CollectionDEID", - column: x => x.CollectionDEID, - principalTable: "Collection", - principalColumn: "ID", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_CollectionLinks_Collection_CollectionID", + name: "FK_CollectionLinks_Collections_CollectionID", column: x => x.CollectionID, - principalTable: "Collection", + principalTable: "Collections", principalColumn: "ID", onDelete: ReferentialAction.Restrict); table.ForeignKey( - name: "FK_CollectionLinks_Show_ShowDEID", - column: x => x.ShowDEID, - principalTable: "Show", - principalColumn: "ID", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_CollectionLinks_Show_ShowID", + name: "FK_CollectionLinks_Shows_ShowID", column: x => x.ShowID, - principalTable: "Show", + principalTable: "Shows", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); @@ -216,35 +191,21 @@ namespace Kyoo.Models.DatabaseMigrations.Internal columns: table => new { ShowID = table.Column(nullable: false), - GenreID = table.Column(nullable: false), - GenreDEID = table.Column(nullable: true), - ShowDEID = table.Column(nullable: true) + GenreID = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_GenreLinks", x => new { x.ShowID, x.GenreID }); table.ForeignKey( - name: "FK_GenreLinks_Genre_GenreDEID", - column: x => x.GenreDEID, - principalTable: "Genre", - principalColumn: "ID", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_GenreLinks_Genre_GenreID", + name: "FK_GenreLinks_Genres_GenreID", column: x => x.GenreID, - principalTable: "Genre", + principalTable: "Genres", principalColumn: "ID", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_GenreLinks_Show_ShowDEID", - column: x => x.ShowDEID, - principalTable: "Show", - principalColumn: "ID", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_GenreLinks_Show_ShowID", + name: "FK_GenreLinks_Shows_ShowID", column: x => x.ShowID, - principalTable: "Show", + principalTable: "Shows", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); @@ -257,48 +218,27 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), LibraryID = table.Column(nullable: false), ShowID = table.Column(nullable: true), - CollectionID = table.Column(nullable: true), - CollectionDEID = table.Column(nullable: true), - LibraryDEID = table.Column(nullable: true), - ShowDEID = table.Column(nullable: true) + CollectionID = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_LibraryLinks", x => x.ID); table.ForeignKey( - name: "FK_LibraryLinks_Collection_CollectionDEID", - column: x => x.CollectionDEID, - principalTable: "Collection", - principalColumn: "ID", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_LibraryLinks_Collection_CollectionID", + name: "FK_LibraryLinks_Collections_CollectionID", column: x => x.CollectionID, - principalTable: "Collection", + principalTable: "Collections", principalColumn: "ID", onDelete: ReferentialAction.Restrict); table.ForeignKey( - name: "FK_LibraryLinks_Library_LibraryDEID", - column: x => x.LibraryDEID, - principalTable: "Library", - principalColumn: "ID", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_LibraryLinks_Library_LibraryID", + name: "FK_LibraryLinks_Libraries_LibraryID", column: x => x.LibraryID, - principalTable: "Library", + principalTable: "Libraries", principalColumn: "ID", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_LibraryLinks_Show_ShowDEID", - column: x => x.ShowDEID, - principalTable: "Show", - principalColumn: "ID", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_LibraryLinks_Show_ShowID", + name: "FK_LibraryLinks_Shows_ShowID", column: x => x.ShowID, - principalTable: "Show", + principalTable: "Shows", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); @@ -324,9 +264,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal principalColumn: "ID", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_PeopleRoles_Show_ShowID", + name: "FK_PeopleRoles_Shows_ShowID", column: x => x.ShowID, - principalTable: "Show", + principalTable: "Shows", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); @@ -342,15 +282,15 @@ namespace Kyoo.Models.DatabaseMigrations.Internal Title = table.Column(nullable: true), Overview = table.Column(nullable: true), Year = table.Column(nullable: true), - ImgPrimary = table.Column(nullable: true) + Poster = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Seasons", x => x.ID); table.ForeignKey( - name: "FK_Seasons_Show_ShowID", + name: "FK_Seasons_Shows_ShowID", column: x => x.ShowID, - principalTable: "Show", + principalTable: "Shows", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); @@ -383,9 +323,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal principalColumn: "ID", onDelete: ReferentialAction.Restrict); table.ForeignKey( - name: "FK_Episodes_Show_ShowID", + name: "FK_Episodes_Shows_ShowID", column: x => x.ShowID, - principalTable: "Show", + principalTable: "Shows", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); @@ -432,9 +372,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal principalColumn: "ID", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_MetadataIds_Show_ShowID", + name: "FK_MetadataIds_Shows_ShowID", column: x => x.ShowID, - principalTable: "Show", + principalTable: "Shows", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); @@ -466,22 +406,6 @@ namespace Kyoo.Models.DatabaseMigrations.Internal onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateIndex( - name: "IX_Collection_Slug", - table: "Collection", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_CollectionLinks_CollectionDEID", - table: "CollectionLinks", - column: "CollectionDEID"); - - migrationBuilder.CreateIndex( - name: "IX_CollectionLinks_ShowDEID", - table: "CollectionLinks", - column: "ShowDEID"); - migrationBuilder.CreateIndex( name: "IX_CollectionLinks_ShowID", table: "CollectionLinks", @@ -493,6 +417,12 @@ namespace Kyoo.Models.DatabaseMigrations.Internal columns: new[] { "CollectionID", "ShowID" }, unique: true); + migrationBuilder.CreateIndex( + name: "IX_Collections_Slug", + table: "Collections", + column: "Slug", + unique: true); + migrationBuilder.CreateIndex( name: "IX_Episodes_SeasonID", table: "Episodes", @@ -504,53 +434,28 @@ namespace Kyoo.Models.DatabaseMigrations.Internal columns: new[] { "ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber" }, unique: true); - migrationBuilder.CreateIndex( - name: "IX_Genre_Slug", - table: "Genre", - column: "Slug", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_GenreLinks_GenreDEID", - table: "GenreLinks", - column: "GenreDEID"); - migrationBuilder.CreateIndex( name: "IX_GenreLinks_GenreID", table: "GenreLinks", column: "GenreID"); migrationBuilder.CreateIndex( - name: "IX_GenreLinks_ShowDEID", - table: "GenreLinks", - column: "ShowDEID"); - - migrationBuilder.CreateIndex( - name: "IX_Library_Slug", - table: "Library", + name: "IX_Genres_Slug", + table: "Genres", column: "Slug", unique: true); migrationBuilder.CreateIndex( - name: "IX_LibraryLinks_CollectionDEID", - table: "LibraryLinks", - column: "CollectionDEID"); + name: "IX_Libraries_Slug", + table: "Libraries", + column: "Slug", + unique: true); migrationBuilder.CreateIndex( name: "IX_LibraryLinks_CollectionID", table: "LibraryLinks", column: "CollectionID"); - migrationBuilder.CreateIndex( - name: "IX_LibraryLinks_LibraryDEID", - table: "LibraryLinks", - column: "LibraryDEID"); - - migrationBuilder.CreateIndex( - name: "IX_LibraryLinks_ShowDEID", - table: "LibraryLinks", - column: "ShowDEID"); - migrationBuilder.CreateIndex( name: "IX_LibraryLinks_ShowID", table: "LibraryLinks", @@ -609,11 +514,6 @@ namespace Kyoo.Models.DatabaseMigrations.Internal table: "PeopleRoles", column: "ShowID"); - migrationBuilder.CreateIndex( - name: "IX_ProviderLinks_LibraryDEID", - table: "ProviderLinks", - column: "LibraryDEID"); - migrationBuilder.CreateIndex( name: "IX_ProviderLinks_LibraryID", table: "ProviderLinks", @@ -637,14 +537,14 @@ namespace Kyoo.Models.DatabaseMigrations.Internal unique: true); migrationBuilder.CreateIndex( - name: "IX_Show_Slug", - table: "Show", + name: "IX_Shows_Slug", + table: "Shows", column: "Slug", unique: true); migrationBuilder.CreateIndex( - name: "IX_Show_StudioID", - table: "Show", + name: "IX_Shows_StudioID", + table: "Shows", column: "StudioID"); migrationBuilder.CreateIndex( @@ -683,16 +583,16 @@ namespace Kyoo.Models.DatabaseMigrations.Internal name: "Tracks"); migrationBuilder.DropTable( - name: "Genre"); + name: "Genres"); migrationBuilder.DropTable( - name: "Collection"); + name: "Collections"); migrationBuilder.DropTable( name: "People"); migrationBuilder.DropTable( - name: "Library"); + name: "Libraries"); migrationBuilder.DropTable( name: "Providers"); @@ -704,7 +604,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal name: "Seasons"); migrationBuilder.DropTable( - name: "Show"); + name: "Shows"); migrationBuilder.DropTable( name: "Studios"); diff --git a/Kyoo/Models/DatabaseMigrations/Internal/DatabaseContextModelSnapshot.cs b/Kyoo/Models/DatabaseMigrations/Internal/DatabaseContextModelSnapshot.cs index 4bc4bc19..a8de1e84 100644 --- a/Kyoo/Models/DatabaseMigrations/Internal/DatabaseContextModelSnapshot.cs +++ b/Kyoo/Models/DatabaseMigrations/Internal/DatabaseContextModelSnapshot.cs @@ -23,17 +23,13 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasAnnotation("ProductVersion", "3.1.3") .HasAnnotation("Relational:MaxIdentifierLength", 63); - modelBuilder.Entity("Kyoo.Models.Collection", b => + modelBuilder.Entity("Kyoo.Models.CollectionDE", b => { b.Property("ID") .ValueGeneratedOnAdd() .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - b.Property("Name") .HasColumnType("text"); @@ -44,6 +40,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -51,9 +48,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.HasIndex("Slug") .IsUnique(); - b.ToTable("Collection"); + b.ToTable("Collections"); - b.HasDiscriminator("Discriminator").HasValue("Collection"); + b.HasDiscriminator(); }); modelBuilder.Entity("Kyoo.Models.CollectionLink", b => @@ -63,24 +60,14 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("CollectionDEID") - .HasColumnType("integer"); - b.Property("CollectionID") .HasColumnType("integer"); - b.Property("ShowDEID") - .HasColumnType("integer"); - b.Property("ShowID") .HasColumnType("integer"); b.HasKey("ID"); - b.HasIndex("CollectionDEID"); - - b.HasIndex("ShowDEID"); - b.HasIndex("ShowID"); b.HasIndex("CollectionID", "ShowID") @@ -139,21 +126,18 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.ToTable("Episodes"); }); - modelBuilder.Entity("Kyoo.Models.Genre", b => + modelBuilder.Entity("Kyoo.Models.GenreDE", b => { b.Property("ID") .ValueGeneratedOnAdd() .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - b.Property("Name") .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -161,9 +145,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.HasIndex("Slug") .IsUnique(); - b.ToTable("Genre"); + b.ToTable("Genres"); - b.HasDiscriminator("Discriminator").HasValue("Genre"); + b.HasDiscriminator(); }); modelBuilder.Entity("Kyoo.Models.GenreLink", b => @@ -174,34 +158,20 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.Property("GenreID") .HasColumnType("integer"); - b.Property("GenreDEID") - .HasColumnType("integer"); - - b.Property("ShowDEID") - .HasColumnType("integer"); - b.HasKey("ShowID", "GenreID"); - b.HasIndex("GenreDEID"); - b.HasIndex("GenreID"); - b.HasIndex("ShowDEID"); - b.ToTable("GenreLinks"); }); - modelBuilder.Entity("Kyoo.Models.Library", b => + modelBuilder.Entity("Kyoo.Models.LibraryDE", b => { b.Property("ID") .ValueGeneratedOnAdd() .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - b.Property("Name") .HasColumnType("text"); @@ -209,6 +179,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text[]"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -216,9 +187,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.HasIndex("Slug") .IsUnique(); - b.ToTable("Library"); + b.ToTable("Libraries"); - b.HasDiscriminator("Discriminator").HasValue("Library"); + b.HasDiscriminator(); }); modelBuilder.Entity("Kyoo.Models.LibraryLink", b => @@ -228,34 +199,19 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("CollectionDEID") - .HasColumnType("integer"); - b.Property("CollectionID") .HasColumnType("integer"); - b.Property("LibraryDEID") - .HasColumnType("integer"); - b.Property("LibraryID") .HasColumnType("integer"); - b.Property("ShowDEID") - .HasColumnType("integer"); - b.Property("ShowID") .HasColumnType("integer"); b.HasKey("ID"); - b.HasIndex("CollectionDEID"); - b.HasIndex("CollectionID"); - b.HasIndex("LibraryDEID"); - - b.HasIndex("ShowDEID"); - b.HasIndex("ShowID"); b.HasIndex("LibraryID", "CollectionID") @@ -324,6 +280,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -376,6 +333,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -393,9 +351,6 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("LibraryDEID") - .HasColumnType("integer"); - b.Property("LibraryID") .HasColumnType("integer"); @@ -404,8 +359,6 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.HasKey("ID"); - b.HasIndex("LibraryDEID"); - b.HasIndex("LibraryID"); b.HasIndex("ProviderID"); @@ -420,10 +373,10 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("integer") .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("ImgPrimary") + b.Property("Overview") .HasColumnType("text"); - b.Property("Overview") + b.Property("Poster") .HasColumnType("text"); b.Property("SeasonNumber") @@ -446,7 +399,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.ToTable("Seasons"); }); - modelBuilder.Entity("Kyoo.Models.Show", b => + modelBuilder.Entity("Kyoo.Models.ShowDE", b => { b.Property("ID") .ValueGeneratedOnAdd() @@ -459,10 +412,6 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.Property("Backdrop") .HasColumnType("text"); - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - b.Property("EndYear") .HasColumnType("integer"); @@ -482,6 +431,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.Property("StartYear") @@ -506,9 +456,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.HasIndex("StudioID"); - b.ToTable("Show"); + b.ToTable("Shows"); - b.HasDiscriminator("Discriminator").HasValue("Show"); + b.HasDiscriminator(); }); modelBuilder.Entity("Kyoo.Models.Studio", b => @@ -522,6 +472,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasColumnType("text"); b.Property("Slug") + .IsRequired() .HasColumnType("text"); b.HasKey("ID"); @@ -573,50 +524,14 @@ namespace Kyoo.Models.DatabaseMigrations.Internal b.ToTable("Tracks"); }); - modelBuilder.Entity("Kyoo.Models.CollectionDE", b => - { - b.HasBaseType("Kyoo.Models.Collection"); - - b.HasDiscriminator().HasValue("CollectionDE"); - }); - - modelBuilder.Entity("Kyoo.Models.GenreDE", b => - { - b.HasBaseType("Kyoo.Models.Genre"); - - b.HasDiscriminator().HasValue("GenreDE"); - }); - - modelBuilder.Entity("Kyoo.Models.LibraryDE", b => - { - b.HasBaseType("Kyoo.Models.Library"); - - b.HasDiscriminator().HasValue("LibraryDE"); - }); - - modelBuilder.Entity("Kyoo.Models.ShowDE", b => - { - b.HasBaseType("Kyoo.Models.Show"); - - b.HasDiscriminator().HasValue("ShowDE"); - }); - modelBuilder.Entity("Kyoo.Models.CollectionLink", b => { - b.HasOne("Kyoo.Models.CollectionDE", null) + b.HasOne("Kyoo.Models.CollectionDE", "Collection") .WithMany("Links") - .HasForeignKey("CollectionDEID"); - - b.HasOne("Kyoo.Models.Collection", "Collection") - .WithMany() .HasForeignKey("CollectionID"); - b.HasOne("Kyoo.Models.ShowDE", null) + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("CollectionLinks") - .HasForeignKey("ShowDEID"); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany() .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -628,7 +543,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .WithMany("Episodes") .HasForeignKey("SeasonID"); - b.HasOne("Kyoo.Models.Show", "Show") + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("Episodes") .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade) @@ -637,22 +552,14 @@ namespace Kyoo.Models.DatabaseMigrations.Internal modelBuilder.Entity("Kyoo.Models.GenreLink", b => { - b.HasOne("Kyoo.Models.GenreDE", null) + b.HasOne("Kyoo.Models.GenreDE", "Genre") .WithMany("Links") - .HasForeignKey("GenreDEID"); - - b.HasOne("Kyoo.Models.Genre", "Genre") - .WithMany() .HasForeignKey("GenreID") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Kyoo.Models.ShowDE", null) + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("GenreLinks") - .HasForeignKey("ShowDEID"); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany() .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -660,30 +567,18 @@ namespace Kyoo.Models.DatabaseMigrations.Internal modelBuilder.Entity("Kyoo.Models.LibraryLink", b => { - b.HasOne("Kyoo.Models.CollectionDE", null) + b.HasOne("Kyoo.Models.CollectionDE", "Collection") .WithMany("LibraryLinks") - .HasForeignKey("CollectionDEID"); - - b.HasOne("Kyoo.Models.Collection", "Collection") - .WithMany() .HasForeignKey("CollectionID"); - b.HasOne("Kyoo.Models.LibraryDE", null) + b.HasOne("Kyoo.Models.LibraryDE", "Library") .WithMany("Links") - .HasForeignKey("LibraryDEID"); - - b.HasOne("Kyoo.Models.Library", "Library") - .WithMany() .HasForeignKey("LibraryID") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Kyoo.Models.ShowDE", null) + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("LibraryLinks") - .HasForeignKey("ShowDEID"); - - b.HasOne("Kyoo.Models.Show", "Show") - .WithMany() .HasForeignKey("ShowID"); }); @@ -710,7 +605,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .HasForeignKey("SeasonID") .OnDelete(DeleteBehavior.Cascade); - b.HasOne("Kyoo.Models.Show", "Show") + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("ExternalIDs") .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade); @@ -724,7 +619,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Kyoo.Models.Show", "Show") + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("People") .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade) @@ -733,12 +628,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal modelBuilder.Entity("Kyoo.Models.ProviderLink", b => { - b.HasOne("Kyoo.Models.LibraryDE", null) + b.HasOne("Kyoo.Models.LibraryDE", "Library") .WithMany("ProviderLinks") - .HasForeignKey("LibraryDEID"); - - b.HasOne("Kyoo.Models.Library", "Library") - .WithMany() .HasForeignKey("LibraryID"); b.HasOne("Kyoo.Models.ProviderID", "Provider") @@ -750,17 +641,17 @@ namespace Kyoo.Models.DatabaseMigrations.Internal modelBuilder.Entity("Kyoo.Models.Season", b => { - b.HasOne("Kyoo.Models.Show", "Show") + b.HasOne("Kyoo.Models.ShowDE", "Show") .WithMany("Seasons") .HasForeignKey("ShowID") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Kyoo.Models.Show", b => + modelBuilder.Entity("Kyoo.Models.ShowDE", b => { b.HasOne("Kyoo.Models.Studio", "Studio") - .WithMany("Shows") + .WithMany() .HasForeignKey("StudioID"); }); diff --git a/Kyoo/Models/Resources/CollectionDE.cs b/Kyoo/Models/Resources/CollectionDE.cs index 413ecd9e..ea68dfeb 100644 --- a/Kyoo/Models/Resources/CollectionDE.cs +++ b/Kyoo/Models/Resources/CollectionDE.cs @@ -1,19 +1,20 @@ using System.Collections.Generic; using System.Linq; using Kyoo.Models.Attributes; +using Newtonsoft.Json; namespace Kyoo.Models { public class CollectionDE : Collection { - [NotMergable] public virtual IEnumerable Links { get; set; } + [JsonIgnore] [NotMergable] public virtual IEnumerable Links { get; set; } public override IEnumerable Shows { get => Links?.Select(x => x.Show); set => Links = value?.Select(x => new CollectionLink(this, x)); } - [NotMergable] public virtual IEnumerable LibraryLinks { get; set; } + [JsonIgnore] [NotMergable] public virtual IEnumerable LibraryLinks { get; set; } public override IEnumerable Libraries { get => LibraryLinks?.Select(x => x.Library); diff --git a/Kyoo/Models/Resources/GenreDE.cs b/Kyoo/Models/Resources/GenreDE.cs index 2a965f1d..aceafb05 100644 --- a/Kyoo/Models/Resources/GenreDE.cs +++ b/Kyoo/Models/Resources/GenreDE.cs @@ -1,14 +1,15 @@ using System.Collections.Generic; using System.Linq; using Kyoo.Models.Attributes; +using Newtonsoft.Json; namespace Kyoo.Models { public class GenreDE : Genre { - [NotMergable] public virtual IEnumerable Links { get; set; } + [JsonIgnore] [NotMergable] public virtual IEnumerable Links { get; set; } - [NotMergable] public override IEnumerable Shows + [JsonIgnore] [NotMergable] public override IEnumerable Shows { get => Links?.Select(x => x.Show); set => Links = value?.Select(x => new GenreLink(x, this)); diff --git a/Kyoo/Models/Resources/LibraryDE.cs b/Kyoo/Models/Resources/LibraryDE.cs index 264b90c0..c474c4fd 100644 --- a/Kyoo/Models/Resources/LibraryDE.cs +++ b/Kyoo/Models/Resources/LibraryDE.cs @@ -1,19 +1,20 @@ using System.Collections.Generic; using System.Linq; using Kyoo.Models.Attributes; +using Newtonsoft.Json; namespace Kyoo.Models { public class LibraryDE : Library { - [NotMergable] public virtual IEnumerable ProviderLinks { get; set; } + [JsonIgnore] [NotMergable] public virtual IEnumerable ProviderLinks { get; set; } public override IEnumerable Providers { get => ProviderLinks?.Select(x => x.Provider); set => ProviderLinks = value?.Select(x => new ProviderLink(x, this)).ToList(); } - [NotMergable] public virtual IEnumerable Links { get; set; } + [JsonIgnore] [NotMergable] public virtual IEnumerable Links { get; set; } public override IEnumerable Shows { get => Links?.Where(x => x.Show != null).Select(x => x.Show); diff --git a/Kyoo/Models/Resources/ShowDE.cs b/Kyoo/Models/Resources/ShowDE.cs index 9d772d93..7343e0fc 100644 --- a/Kyoo/Models/Resources/ShowDE.cs +++ b/Kyoo/Models/Resources/ShowDE.cs @@ -1,26 +1,30 @@ using System.Collections.Generic; using System.Linq; using Kyoo.Models.Attributes; +using Newtonsoft.Json; + + +// TODO Remove every [JsonIgnore] tag from here once the serializer knows which property should be serialized. namespace Kyoo.Models { public class ShowDE : Show { - [NotMergable] public virtual IEnumerable GenreLinks { get; set; } + [JsonIgnore] [NotMergable] public virtual IEnumerable GenreLinks { get; set; } public override IEnumerable Genres { get => GenreLinks?.Select(x => x.Genre); set => GenreLinks = value?.Select(x => new GenreLink(this, x)).ToList(); } - [NotMergable] public virtual IEnumerable LibraryLinks { get; set; } + [JsonIgnore] [NotMergable] public virtual IEnumerable LibraryLinks { get; set; } public override IEnumerable Libraries { get => LibraryLinks?.Select(x => x.Library); set => LibraryLinks = value?.Select(x => new LibraryLink(x, this)); } - [NotMergable] public virtual IEnumerable CollectionLinks { get; set; } + [JsonIgnore] [NotMergable] public virtual IEnumerable CollectionLinks { get; set; } public override IEnumerable Collections { diff --git a/Kyoo/Startup.cs b/Kyoo/Startup.cs index d6ff4004..673431da 100644 --- a/Kyoo/Startup.cs +++ b/Kyoo/Startup.cs @@ -46,9 +46,9 @@ namespace Kyoo services.AddDbContext(options => { options.UseLazyLoadingProxies() - .UseNpgsql(_configuration.GetConnectionString("Database")); - // .EnableSensitiveDataLogging() - // .UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole())); + .UseNpgsql(_configuration.GetConnectionString("Database")) + .EnableSensitiveDataLogging() + .UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole())); }, ServiceLifetime.Transient); services.AddDbContext(options =>