From 11527e332ce28a5f47d47f5741df82f69435ff13 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 15 Jun 2021 16:25:59 +0100 Subject: [PATCH] We no longer block you from Requesting all seasons if we already have Season 1 Available/Requested. We will just request the delta now! For example if we request Season 1 and we have the first 3 episodes requested, we will skip those and request the remaining #2709 --- .../Request/ExistingPlexRequestRuleTests.cs | 209 +++++++ .../Request/ExistingTvRequestRuleTests.cs | 215 ++++++++ .../Rules/Request/ExistingPlexRequestRule.cs | 20 +- .../Rules/Request/ExistingTVRequestRule.cs | 24 +- src/Ombi.Core/Rule/Rules/SonarrCacheRule.cs | 29 +- src/Ombi.Schedule/Jobs/Sonarr/SonarrSync.cs | 66 ++- src/Ombi.Store/Entities/SonarrCache.cs | 1 + src/Ombi.Store/Entities/SonarrEpisodeCache.cs | 1 + ...15152049_SonarrSyncMovieDbData.Designer.cs | 513 ++++++++++++++++++ .../20210615152049_SonarrSyncMovieDbData.cs | 35 ++ .../ExternalMySqlContextModelSnapshot.cs | 6 + ...15145321_SonarrSyncMovieDbData.Designer.cs | 512 +++++++++++++++++ .../20210615145321_SonarrSyncMovieDbData.cs | 35 ++ .../ExternalSqliteContextModelSnapshot.cs | 6 + 14 files changed, 1646 insertions(+), 26 deletions(-) create mode 100644 src/Ombi.Core.Tests/Rule/Request/ExistingPlexRequestRuleTests.cs create mode 100644 src/Ombi.Core.Tests/Rule/Request/ExistingTvRequestRuleTests.cs create mode 100644 src/Ombi.Store/Migrations/ExternalMySql/20210615152049_SonarrSyncMovieDbData.Designer.cs create mode 100644 src/Ombi.Store/Migrations/ExternalMySql/20210615152049_SonarrSyncMovieDbData.cs create mode 100644 src/Ombi.Store/Migrations/ExternalSqlite/20210615145321_SonarrSyncMovieDbData.Designer.cs create mode 100644 src/Ombi.Store/Migrations/ExternalSqlite/20210615145321_SonarrSyncMovieDbData.cs diff --git a/src/Ombi.Core.Tests/Rule/Request/ExistingPlexRequestRuleTests.cs b/src/Ombi.Core.Tests/Rule/Request/ExistingPlexRequestRuleTests.cs new file mode 100644 index 000000000..f5a362303 --- /dev/null +++ b/src/Ombi.Core.Tests/Rule/Request/ExistingPlexRequestRuleTests.cs @@ -0,0 +1,209 @@ +using MockQueryable.Moq; +using Moq; +using NUnit.Framework; +using Ombi.Core.Rule.Rules.Request; +using Ombi.Store.Entities; +using Ombi.Store.Entities.Requests; +using Ombi.Store.Repository; +using Ombi.Store.Repository.Requests; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ombi.Core.Tests.Rule.Request +{ + [TestFixture] + public class ExistingPlexRequestRuleTests + { + private ExistingPlexRequestRule Rule; + private Mock PlexContentRepo; + + [SetUp] + public void SetUp() + { + PlexContentRepo = new Mock(); + Rule = new ExistingPlexRequestRule(PlexContentRepo.Object); + } + + [Test] + public async Task RequestShow_DoesNotExistAtAll_IsSuccessful() + { + PlexContentRepo.Setup(x => x.GetAll()).Returns(new List().AsQueryable().BuildMock().Object); + var req = new ChildRequests + { + SeasonRequests = new List + { + new SeasonRequests + { + Episodes = new List + { + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 1, + } + }, + SeasonNumber = 1 + } + } + }; + var result = await Rule.Execute(req); + + + Assert.That(result.Success, Is.True); + } + + [Test] + public async Task RequestShow_AllEpisodesAreaRequested_IsNotSuccessful() + { + SetupMockData(); + + var req = new ChildRequests + { + SeasonRequests = new List + { + new SeasonRequests + { + Episodes = new List + { + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 1, + }, + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 2, + }, + }, + SeasonNumber = 1 + } + }, + Id = 1, + }; + var result = await Rule.Execute(req); + + + Assert.That(result.Success, Is.False); + } + + + [Test] + public async Task RequestShow_SomeEpisodesAreaRequested_IsSuccessful() + { + SetupMockData(); + + var req = new ChildRequests + { + RequestType = RequestType.TvShow, + SeasonRequests = new List + { + new SeasonRequests + { + Episodes = new List + { + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 1, + }, + new EpisodeRequests + { + Id = 2, + EpisodeNumber = 2, + }, + new EpisodeRequests + { + Id = 3, + EpisodeNumber = 3, + }, + }, + SeasonNumber = 1 + } + }, + Id = 1, + }; + var result = await Rule.Execute(req); + + + Assert.That(result.Success, Is.True); + + var episodes = req.SeasonRequests.SelectMany(x => x.Episodes); + Assert.That(episodes.Count() == 1, "We didn't remove the episodes that have already been requested!"); + Assert.That(episodes.First().EpisodeNumber == 3, "We removed the wrong episode"); + } + + [Test] + public async Task RequestShow_NewSeasonRequest_IsSuccessful() + { + SetupMockData(); + + var req = new ChildRequests + { + RequestType = RequestType.TvShow, + SeasonRequests = new List + { + new SeasonRequests + { + Episodes = new List + { + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 1, + }, + new EpisodeRequests + { + Id = 2, + EpisodeNumber = 2, + }, + new EpisodeRequests + { + Id = 3, + EpisodeNumber = 3, + }, + }, + SeasonNumber = 2 + } + }, + Id = 1, + }; + var result = await Rule.Execute(req); + + Assert.That(result.Success, Is.True); + } + + private void SetupMockData() + { + var childRequests = new List + { + new PlexServerContent + { + Type = PlexMediaTypeEntity.Show, + TheMovieDbId = "1", + Title = "Test", + ReleaseYear = "2001", + Episodes = new List + { + new PlexEpisode + { + EpisodeNumber = 1, + Id = 1, + SeasonNumber = 1, + }, + new PlexEpisode + { + EpisodeNumber = 2, + Id = 2, + SeasonNumber = 1, + }, + } + } + }; + PlexContentRepo.Setup(x => x.GetAll()).Returns(childRequests.AsQueryable().BuildMock().Object); + } + } +} diff --git a/src/Ombi.Core.Tests/Rule/Request/ExistingTvRequestRuleTests.cs b/src/Ombi.Core.Tests/Rule/Request/ExistingTvRequestRuleTests.cs new file mode 100644 index 000000000..d5ca903bf --- /dev/null +++ b/src/Ombi.Core.Tests/Rule/Request/ExistingTvRequestRuleTests.cs @@ -0,0 +1,215 @@ +using MockQueryable.Moq; +using Moq; +using NUnit.Framework; +using Ombi.Core.Rule.Rules.Request; +using Ombi.Store.Entities; +using Ombi.Store.Entities.Requests; +using Ombi.Store.Repository.Requests; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ombi.Core.Tests.Rule.Request +{ + [TestFixture] + public class ExistingTvRequestRuleTests + { + private ExistingTvRequestRule Rule; + private Mock TvRequestRepo; + + [SetUp] + public void SetUp() + { + TvRequestRepo = new Mock(); + Rule = new ExistingTvRequestRule(TvRequestRepo.Object); + } + + [Test] + public async Task RequestShow_DoesNotExistAtAll_IsSuccessful() + { + TvRequestRepo.Setup(x => x.GetChild()).Returns(new List().AsQueryable().BuildMock().Object); + var req = new ChildRequests + { + SeasonRequests = new List + { + new SeasonRequests + { + Episodes = new List + { + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 1, + } + }, + SeasonNumber = 1 + } + } + }; + var result = await Rule.Execute(req); + + + Assert.That(result.Success, Is.True); + } + + [Test] + public async Task RequestShow_AllEpisodesAreaRequested_IsNotSuccessful() + { + SetupMockData(); + + var req = new ChildRequests + { + SeasonRequests = new List + { + new SeasonRequests + { + Episodes = new List + { + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 1, + }, + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 2, + }, + }, + SeasonNumber = 1 + } + }, + Id = 1, + }; + var result = await Rule.Execute(req); + + + Assert.That(result.Success, Is.False); + } + + + [Test] + public async Task RequestShow_SomeEpisodesAreaRequested_IsSuccessful() + { + SetupMockData(); + + var req = new ChildRequests + { + RequestType = RequestType.TvShow, + SeasonRequests = new List + { + new SeasonRequests + { + Episodes = new List + { + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 1, + }, + new EpisodeRequests + { + Id = 2, + EpisodeNumber = 2, + }, + new EpisodeRequests + { + Id = 3, + EpisodeNumber = 3, + }, + }, + SeasonNumber = 1 + } + }, + Id = 1, + }; + var result = await Rule.Execute(req); + + + Assert.That(result.Success, Is.True); + + var episodes = req.SeasonRequests.SelectMany(x => x.Episodes); + Assert.That(episodes.Count() == 1, "We didn't remove the episodes that have already been requested!"); + Assert.That(episodes.First().EpisodeNumber == 3, "We removed the wrong episode"); + } + + [Test] + public async Task RequestShow_NewSeasonRequest_IsSuccessful() + { + SetupMockData(); + + var req = new ChildRequests + { + RequestType = RequestType.TvShow, + SeasonRequests = new List + { + new SeasonRequests + { + Episodes = new List + { + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 1, + }, + new EpisodeRequests + { + Id = 2, + EpisodeNumber = 2, + }, + new EpisodeRequests + { + Id = 3, + EpisodeNumber = 3, + }, + }, + SeasonNumber = 2 + } + }, + Id = 1, + }; + var result = await Rule.Execute(req); + + Assert.That(result.Success, Is.True); + } + + private void SetupMockData() + { + var childRequests = new List + { + new ChildRequests + { + ParentRequest = new TvRequests + { + Id = 1, + ExternalProviderId = 1, + }, + SeasonRequests = new List + { + new SeasonRequests + { + Id = 1, + SeasonNumber = 1, + Episodes = new List + { + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 1, + }, + new EpisodeRequests + { + Id = 1, + EpisodeNumber = 2, + } + } + } + } + } + }; + TvRequestRepo.Setup(x => x.GetChild()).Returns(childRequests.AsQueryable().BuildMock().Object); + } + } +} diff --git a/src/Ombi.Core/Rule/Rules/Request/ExistingPlexRequestRule.cs b/src/Ombi.Core/Rule/Rules/Request/ExistingPlexRequestRule.cs index 927ebf1be..10ab93bed 100644 --- a/src/Ombi.Core/Rule/Rules/Request/ExistingPlexRequestRule.cs +++ b/src/Ombi.Core/Rule/Rules/Request/ExistingPlexRequestRule.cs @@ -7,6 +7,7 @@ using Ombi.Core.Rule.Interfaces; using Ombi.Store.Entities; using Ombi.Store.Entities.Requests; using Ombi.Store.Repository; +using Ombi.Store.Repository.Requests; namespace Ombi.Core.Rule.Rules.Request { @@ -60,6 +61,7 @@ namespace Ombi.Core.Rule.Rules.Request { foreach (var season in child.SeasonRequests) { + var episodesToRemove = new List(); var currentSeasonRequest = content.Episodes.Where(x => x.SeasonNumber == season.SeasonNumber).ToList(); if (!currentSeasonRequest.Any()) @@ -68,12 +70,24 @@ namespace Ombi.Core.Rule.Rules.Request } foreach (var e in season.Episodes) { - var hasEpisode = currentSeasonRequest.Any(x => x.EpisodeNumber == e.EpisodeNumber); - if (hasEpisode) + var existingEpRequest = currentSeasonRequest.FirstOrDefault(x => x.EpisodeNumber == e.EpisodeNumber); + if (existingEpRequest != null) { - return Fail($"We already have episodes requested from series {child.Title}"); + episodesToRemove.Add(e); } } + + episodesToRemove.ForEach(x => + { + season.Episodes.Remove(x); + }); + } + + var anyEpisodes = child.SeasonRequests.SelectMany(x => x.Episodes).Any(); + + if (!anyEpisodes) + { + return Fail($"We already have episodes requested from series {child.Title}"); } return Success(); diff --git a/src/Ombi.Core/Rule/Rules/Request/ExistingTVRequestRule.cs b/src/Ombi.Core/Rule/Rules/Request/ExistingTVRequestRule.cs index 02546d356..7973f664b 100644 --- a/src/Ombi.Core/Rule/Rules/Request/ExistingTVRequestRule.cs +++ b/src/Ombi.Core/Rule/Rules/Request/ExistingTVRequestRule.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Ombi.Core.Rule.Interfaces; @@ -41,15 +42,30 @@ namespace Ombi.Core.Rule.Rules.Request { continue; } + + var episodesToRemove = new List(); foreach (var e in season.Episodes) { - var hasEpisode = currentSeasonRequest.Episodes.Any(x => x.EpisodeNumber == e.EpisodeNumber); - if (hasEpisode) + var existingEpRequest = currentSeasonRequest.Episodes.FirstOrDefault(x => x.EpisodeNumber == e.EpisodeNumber); + if (existingEpRequest != null) { - return Fail($"We already have episodes requested from series {tv.Title}"); + episodesToRemove.Add(e); } } + + episodesToRemove.ForEach(x => + { + season.Episodes.Remove(x); + }); + } + + var anyEpisodes = tv.SeasonRequests.SelectMany(x => x.Episodes).Any(); + + if (!anyEpisodes) + { + return Fail($"We already have episodes requested from series {tv.Title}"); } + } return Success(); } diff --git a/src/Ombi.Core/Rule/Rules/SonarrCacheRule.cs b/src/Ombi.Core/Rule/Rules/SonarrCacheRule.cs index 0e4313ac7..325b7cc8d 100644 --- a/src/Ombi.Core/Rule/Rules/SonarrCacheRule.cs +++ b/src/Ombi.Core/Rule/Rules/SonarrCacheRule.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Ombi.Core.Models.Search; @@ -6,6 +7,7 @@ using Ombi.Helpers; using Ombi.Store.Context; using Ombi.Store.Entities; using Ombi.Store.Entities.Requests; +using Ombi.Store.Repository.Requests; namespace Ombi.Core.Rule.Rules { @@ -23,7 +25,7 @@ namespace Ombi.Core.Rule.Rules if (obj.RequestType == RequestType.TvShow) { var vm = (ChildRequests) obj; - var result = await _ctx.SonarrCache.FirstOrDefaultAsync(x => x.TvDbId == vm.Id); // TODO lookup the external provider in the sonarr sync to use themoviedb + var result = await _ctx.SonarrCache.FirstOrDefaultAsync(x => x.TheMovieDbId == vm.Id); if (result != null) { if (vm.SeasonRequests.Any()) @@ -31,17 +33,30 @@ namespace Ombi.Core.Rule.Rules var sonarrEpisodes = _ctx.SonarrEpisodeCache; foreach (var season in vm.SeasonRequests) { + var toRemove = new List(); foreach (var ep in season.Episodes) { // Check if we have it - var monitoredInSonarr = sonarrEpisodes.Any(x => + var monitoredInSonarr = sonarrEpisodes.FirstOrDefault(x => x.EpisodeNumber == ep.EpisodeNumber && x.SeasonNumber == season.SeasonNumber - && x.TvDbId == vm.Id); - if (monitoredInSonarr) + && x.MovieDbId == vm.Id); + if (monitoredInSonarr != null) { - return new RuleResult{Message = "We already have this request, please choose the \"Select...\" option to refine your request"}; - } + toRemove.Add(ep); + } } + + toRemove.ForEach(x => + { + season.Episodes.Remove(x); + }); + + } + var anyEpisodes = vm.SeasonRequests.SelectMany(x => x.Episodes).Any(); + + if (!anyEpisodes) + { + return new RuleResult { Message = $"We already have episodes requested from series {vm.Title}" }; } } } diff --git a/src/Ombi.Schedule/Jobs/Sonarr/SonarrSync.cs b/src/Ombi.Schedule/Jobs/Sonarr/SonarrSync.cs index 82c699598..cf13fb037 100644 --- a/src/Ombi.Schedule/Jobs/Sonarr/SonarrSync.cs +++ b/src/Ombi.Schedule/Jobs/Sonarr/SonarrSync.cs @@ -9,6 +9,8 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Ombi.Api.Sonarr; using Ombi.Api.Sonarr.Models; +using Ombi.Api.TheMovieDb; +using Ombi.Api.TheMovieDb.Models; using Ombi.Core.Settings; using Ombi.Helpers; using Ombi.Schedule.Jobs.Radarr; @@ -21,12 +23,14 @@ namespace Ombi.Schedule.Jobs.Sonarr { public class SonarrSync : ISonarrSync { - public SonarrSync(ISettingsService s, ISonarrApi api, ILogger l, ExternalContext ctx) + public SonarrSync(ISettingsService s, ISonarrApi api, ILogger l, ExternalContext ctx, + IMovieDbApi movieDbApi) { _settings = s; _api = api; _log = l; _ctx = ctx; + _movieDbApi = movieDbApi; _settings.ClearCache(); } @@ -34,6 +38,7 @@ namespace Ombi.Schedule.Jobs.Sonarr private readonly ISonarrApi _api; private readonly ILogger _log; private readonly ExternalContext _ctx; + private readonly IMovieDbApi _movieDbApi; public async Task Execute(IJobExecutionContext job) { @@ -48,7 +53,17 @@ namespace Ombi.Schedule.Jobs.Sonarr if (series != null) { var sonarrSeries = series as ImmutableHashSet ?? series.ToImmutableHashSet(); - var ids = sonarrSeries.Select(x => x.tvdbId); + var ids = sonarrSeries.Select(x => new SonarrDto + { + TvDbId = x.tvdbId, + ImdbId = x.imdbId, + Title = x.title, + MovieDbId = 0, + Id = x.id, + Monitored = x.monitored, + EpisodeFileCount = x.episodeFileCount + }).ToHashSet(); + var strat = _ctx.Database.CreateExecutionStrategy(); await strat.ExecuteAsync(async () => { @@ -60,12 +75,27 @@ namespace Ombi.Schedule.Jobs.Sonarr }); var existingSeries = await _ctx.SonarrCache.Select(x => x.TvDbId).ToListAsync(); - - //var entites = ids.Except(existingSeries).Select(id => new SonarrCache { TvDbId = id }).ToImmutableHashSet(); - var entites = ids.Select(id => new SonarrCache { TvDbId = id }).ToImmutableHashSet(); - await _ctx.SonarrCache.AddRangeAsync(entites); - entites.Clear(); + var sonarrCacheToSave = new HashSet(); + foreach (var id in ids) + { + var cache = new SonarrCache + { + TvDbId = id.TvDbId + }; + + var findResult = await _movieDbApi.Find(id.TvDbId.ToString(), ExternalSource.tvdb_id); + if (findResult.tv_results.Any()) + { + cache.TheMovieDbId = findResult.tv_results.FirstOrDefault()?.id ?? -1; + id.MovieDbId = cache.TheMovieDbId; + } + sonarrCacheToSave.Add(cache); + } + + await _ctx.SonarrCache.AddRangeAsync(sonarrCacheToSave); + await _ctx.SaveChangesAsync(); + sonarrCacheToSave.Clear(); strat = _ctx.Database.CreateExecutionStrategy(); await strat.ExecuteAsync(async () => { @@ -76,15 +106,15 @@ namespace Ombi.Schedule.Jobs.Sonarr } }); - foreach (var s in sonarrSeries) + foreach (var s in ids) { - if (!s.monitored || s.episodeFileCount == 0) // We have files + if (!s.Monitored || s.EpisodeFileCount == 0) // We have files { continue; } - _log.LogDebug("Syncing series: {0}", s.title); - var episodes = await _api.GetEpisodes(s.id, settings.ApiKey, settings.FullUri); + _log.LogDebug("Syncing series: {0}", s.Title); + var episodes = await _api.GetEpisodes(s.Id, settings.ApiKey, settings.FullUri); var monitoredEpisodes = episodes.Where(x => x.monitored || x.hasFile); //var allExistingEpisodes = await _ctx.SonarrEpisodeCache.Where(x => x.TvDbId == s.tvdbId).ToListAsync(); @@ -95,7 +125,8 @@ namespace Ombi.Schedule.Jobs.Sonarr { EpisodeNumber = episode.episodeNumber, SeasonNumber = episode.seasonNumber, - TvDbId = s.tvdbId, + TvDbId = s.TvDbId, + MovieDbId = s.MovieDbId, HasFile = episode.hasFile }); //var episodesToAdd = new List(); @@ -166,5 +197,16 @@ namespace Ombi.Schedule.Jobs.Sonarr Dispose(true); GC.SuppressFinalize(this); } + + private class SonarrDto + { + public int TvDbId { get; set; } + public string ImdbId { get; set; } + public string Title { get; set; } + public int MovieDbId { get; set; } + public int Id { get; set; } + public bool Monitored { get; set; } + public int EpisodeFileCount { get; set; } + } } } \ No newline at end of file diff --git a/src/Ombi.Store/Entities/SonarrCache.cs b/src/Ombi.Store/Entities/SonarrCache.cs index 33e06f7d9..ab3ff7715 100644 --- a/src/Ombi.Store/Entities/SonarrCache.cs +++ b/src/Ombi.Store/Entities/SonarrCache.cs @@ -6,5 +6,6 @@ namespace Ombi.Store.Entities public class SonarrCache : Entity { public int TvDbId { get; set; } + public int TheMovieDbId { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Store/Entities/SonarrEpisodeCache.cs b/src/Ombi.Store/Entities/SonarrEpisodeCache.cs index 59a97b5d2..9f9d791f0 100644 --- a/src/Ombi.Store/Entities/SonarrEpisodeCache.cs +++ b/src/Ombi.Store/Entities/SonarrEpisodeCache.cs @@ -8,6 +8,7 @@ namespace Ombi.Store.Entities public int SeasonNumber { get; set; } public int EpisodeNumber { get; set; } public int TvDbId { get; set; } + public int MovieDbId { get; set; } public bool HasFile { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Store/Migrations/ExternalMySql/20210615152049_SonarrSyncMovieDbData.Designer.cs b/src/Ombi.Store/Migrations/ExternalMySql/20210615152049_SonarrSyncMovieDbData.Designer.cs new file mode 100644 index 000000000..db4090c7c --- /dev/null +++ b/src/Ombi.Store/Migrations/ExternalMySql/20210615152049_SonarrSyncMovieDbData.Designer.cs @@ -0,0 +1,513 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context.MySql; + +namespace Ombi.Store.Migrations.ExternalMySql +{ + [DbContext(typeof(ExternalMySqlContext))] + [Migration("20210615152049_SonarrSyncMovieDbData")] + partial class SonarrSyncMovieDbData + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.1"); + + modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("CouchPotatoCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AddedAt") + .HasColumnType("datetime(6)"); + + b.Property("EmbyId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("ImdbId") + .HasColumnType("longtext"); + + b.Property("ProviderId") + .HasColumnType("longtext"); + + b.Property("TheMovieDbId") + .HasColumnType("longtext"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.Property("TvDbId") + .HasColumnType("longtext"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("Url") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("EmbyContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AddedAt") + .HasColumnType("datetime(6)"); + + b.Property("EmbyId") + .HasColumnType("longtext"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("ImdbId") + .HasColumnType("longtext"); + + b.Property("ParentId") + .HasColumnType("varchar(255)"); + + b.Property("ProviderId") + .HasColumnType("longtext"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("longtext"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.Property("TvDbId") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("EmbyEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AddedAt") + .HasColumnType("datetime(6)"); + + b.Property("ImdbId") + .HasColumnType("longtext"); + + b.Property("JellyfinId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("ProviderId") + .HasColumnType("longtext"); + + b.Property("TheMovieDbId") + .HasColumnType("longtext"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.Property("TvDbId") + .HasColumnType("longtext"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("Url") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("JellyfinContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AddedAt") + .HasColumnType("datetime(6)"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("ImdbId") + .HasColumnType("longtext"); + + b.Property("JellyfinId") + .HasColumnType("longtext"); + + b.Property("ParentId") + .HasColumnType("varchar(255)"); + + b.Property("ProviderId") + .HasColumnType("longtext"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("longtext"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.Property("TvDbId") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("JellyfinEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.LidarrAlbumCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AddedAt") + .HasColumnType("datetime(6)"); + + b.Property("ArtistId") + .HasColumnType("int"); + + b.Property("ForeignAlbumId") + .HasColumnType("longtext"); + + b.Property("Monitored") + .HasColumnType("tinyint(1)"); + + b.Property("PercentOfTracks") + .HasColumnType("decimal(65,30)"); + + b.Property("ReleaseDate") + .HasColumnType("datetime(6)"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.Property("TrackCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("LidarrAlbumCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.LidarrArtistCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ArtistId") + .HasColumnType("int"); + + b.Property("ArtistName") + .HasColumnType("longtext"); + + b.Property("ForeignArtistId") + .HasColumnType("longtext"); + + b.Property("Monitored") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.ToTable("LidarrArtistCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("GrandparentKey") + .HasColumnType("int"); + + b.Property("Key") + .HasColumnType("int"); + + b.Property("ParentKey") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("GrandparentKey"); + + b.ToTable("PlexEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ParentKey") + .HasColumnType("int"); + + b.Property("PlexContentId") + .HasColumnType("int"); + + b.Property("PlexServerContentId") + .HasColumnType("int"); + + b.Property("SeasonKey") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PlexServerContentId"); + + b.ToTable("PlexSeasonsContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AddedAt") + .HasColumnType("datetime(6)"); + + b.Property("ImdbId") + .HasColumnType("longtext"); + + b.Property("Key") + .HasColumnType("int"); + + b.Property("Quality") + .HasColumnType("longtext"); + + b.Property("ReleaseYear") + .HasColumnType("longtext"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("longtext"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.Property("TvDbId") + .HasColumnType("longtext"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("Url") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("PlexServerContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RadarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("HasFile") + .HasColumnType("tinyint(1)"); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("RadarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SickRageCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SickRageCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SickRageEpisodeCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SickRageEpisodeCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SonarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrEpisodeCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("HasFile") + .HasColumnType("tinyint(1)"); + + b.Property("MovieDbId") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("SonarrEpisodeCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.HasOne("Ombi.Store.Entities.EmbyContent", "Series") + .WithMany("Episodes") + .HasForeignKey("ParentId") + .HasPrincipalKey("EmbyId"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinEpisode", b => + { + b.HasOne("Ombi.Store.Entities.JellyfinContent", "Series") + .WithMany("Episodes") + .HasForeignKey("ParentId") + .HasPrincipalKey("JellyfinId"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.HasOne("Ombi.Store.Entities.PlexServerContent", "Series") + .WithMany("Episodes") + .HasForeignKey("GrandparentKey") + .HasPrincipalKey("Key") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.HasOne("Ombi.Store.Entities.PlexServerContent", null) + .WithMany("Seasons") + .HasForeignKey("PlexServerContentId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b => + { + b.Navigation("Episodes"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinContent", b => + { + b.Navigation("Episodes"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b => + { + b.Navigation("Episodes"); + + b.Navigation("Seasons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/ExternalMySql/20210615152049_SonarrSyncMovieDbData.cs b/src/Ombi.Store/Migrations/ExternalMySql/20210615152049_SonarrSyncMovieDbData.cs new file mode 100644 index 000000000..324dcc2f9 --- /dev/null +++ b/src/Ombi.Store/Migrations/ExternalMySql/20210615152049_SonarrSyncMovieDbData.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Ombi.Store.Migrations.ExternalMySql +{ + public partial class SonarrSyncMovieDbData : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "MovieDbId", + table: "SonarrEpisodeCache", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TheMovieDbId", + table: "SonarrCache", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "MovieDbId", + table: "SonarrEpisodeCache"); + + migrationBuilder.DropColumn( + name: "TheMovieDbId", + table: "SonarrCache"); + } + } +} diff --git a/src/Ombi.Store/Migrations/ExternalMySql/ExternalMySqlContextModelSnapshot.cs b/src/Ombi.Store/Migrations/ExternalMySql/ExternalMySqlContextModelSnapshot.cs index 00b274c52..dbdbe6f55 100644 --- a/src/Ombi.Store/Migrations/ExternalMySql/ExternalMySqlContextModelSnapshot.cs +++ b/src/Ombi.Store/Migrations/ExternalMySql/ExternalMySqlContextModelSnapshot.cs @@ -413,6 +413,9 @@ namespace Ombi.Store.Migrations.ExternalMySql .ValueGeneratedOnAdd() .HasColumnType("int"); + b.Property("TheMovieDbId") + .HasColumnType("int"); + b.Property("TvDbId") .HasColumnType("int"); @@ -433,6 +436,9 @@ namespace Ombi.Store.Migrations.ExternalMySql b.Property("HasFile") .HasColumnType("tinyint(1)"); + b.Property("MovieDbId") + .HasColumnType("int"); + b.Property("SeasonNumber") .HasColumnType("int"); diff --git a/src/Ombi.Store/Migrations/ExternalSqlite/20210615145321_SonarrSyncMovieDbData.Designer.cs b/src/Ombi.Store/Migrations/ExternalSqlite/20210615145321_SonarrSyncMovieDbData.Designer.cs new file mode 100644 index 000000000..62aa1e386 --- /dev/null +++ b/src/Ombi.Store/Migrations/ExternalSqlite/20210615145321_SonarrSyncMovieDbData.Designer.cs @@ -0,0 +1,512 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context.Sqlite; + +namespace Ombi.Store.Migrations.ExternalSqlite +{ + [DbContext(typeof(ExternalSqliteContext))] + [Migration("20210615145321_SonarrSyncMovieDbData")] + partial class SonarrSyncMovieDbData + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "5.0.1"); + + modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("TheMovieDbId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("CouchPotatoCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AddedAt") + .HasColumnType("TEXT"); + + b.Property("EmbyId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ImdbId") + .HasColumnType("TEXT"); + + b.Property("ProviderId") + .HasColumnType("TEXT"); + + b.Property("TheMovieDbId") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("TvDbId") + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("Url") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("EmbyContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AddedAt") + .HasColumnType("TEXT"); + + b.Property("EmbyId") + .HasColumnType("TEXT"); + + b.Property("EpisodeNumber") + .HasColumnType("INTEGER"); + + b.Property("ImdbId") + .HasColumnType("TEXT"); + + b.Property("ParentId") + .HasColumnType("TEXT"); + + b.Property("ProviderId") + .HasColumnType("TEXT"); + + b.Property("SeasonNumber") + .HasColumnType("INTEGER"); + + b.Property("TheMovieDbId") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("TvDbId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("EmbyEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AddedAt") + .HasColumnType("TEXT"); + + b.Property("ImdbId") + .HasColumnType("TEXT"); + + b.Property("JellyfinId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ProviderId") + .HasColumnType("TEXT"); + + b.Property("TheMovieDbId") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("TvDbId") + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("Url") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("JellyfinContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AddedAt") + .HasColumnType("TEXT"); + + b.Property("EpisodeNumber") + .HasColumnType("INTEGER"); + + b.Property("ImdbId") + .HasColumnType("TEXT"); + + b.Property("JellyfinId") + .HasColumnType("TEXT"); + + b.Property("ParentId") + .HasColumnType("TEXT"); + + b.Property("ProviderId") + .HasColumnType("TEXT"); + + b.Property("SeasonNumber") + .HasColumnType("INTEGER"); + + b.Property("TheMovieDbId") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("TvDbId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("JellyfinEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.LidarrAlbumCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AddedAt") + .HasColumnType("TEXT"); + + b.Property("ArtistId") + .HasColumnType("INTEGER"); + + b.Property("ForeignAlbumId") + .HasColumnType("TEXT"); + + b.Property("Monitored") + .HasColumnType("INTEGER"); + + b.Property("PercentOfTracks") + .HasColumnType("TEXT"); + + b.Property("ReleaseDate") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("TrackCount") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("LidarrAlbumCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.LidarrArtistCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ArtistId") + .HasColumnType("INTEGER"); + + b.Property("ArtistName") + .HasColumnType("TEXT"); + + b.Property("ForeignArtistId") + .HasColumnType("TEXT"); + + b.Property("Monitored") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("LidarrArtistCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EpisodeNumber") + .HasColumnType("INTEGER"); + + b.Property("GrandparentKey") + .HasColumnType("INTEGER"); + + b.Property("Key") + .HasColumnType("INTEGER"); + + b.Property("ParentKey") + .HasColumnType("INTEGER"); + + b.Property("SeasonNumber") + .HasColumnType("INTEGER"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("GrandparentKey"); + + b.ToTable("PlexEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ParentKey") + .HasColumnType("INTEGER"); + + b.Property("PlexContentId") + .HasColumnType("INTEGER"); + + b.Property("PlexServerContentId") + .HasColumnType("INTEGER"); + + b.Property("SeasonKey") + .HasColumnType("INTEGER"); + + b.Property("SeasonNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("PlexServerContentId"); + + b.ToTable("PlexSeasonsContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AddedAt") + .HasColumnType("TEXT"); + + b.Property("ImdbId") + .HasColumnType("TEXT"); + + b.Property("Key") + .HasColumnType("INTEGER"); + + b.Property("Quality") + .HasColumnType("TEXT"); + + b.Property("ReleaseYear") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("TheMovieDbId") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("TvDbId") + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("Url") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("PlexServerContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RadarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("HasFile") + .HasColumnType("INTEGER"); + + b.Property("TheMovieDbId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("RadarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SickRageCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("TvDbId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("SickRageCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SickRageEpisodeCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EpisodeNumber") + .HasColumnType("INTEGER"); + + b.Property("SeasonNumber") + .HasColumnType("INTEGER"); + + b.Property("TvDbId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("SickRageEpisodeCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("TheMovieDbId") + .HasColumnType("INTEGER"); + + b.Property("TvDbId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("SonarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrEpisodeCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EpisodeNumber") + .HasColumnType("INTEGER"); + + b.Property("HasFile") + .HasColumnType("INTEGER"); + + b.Property("MovieDbId") + .HasColumnType("INTEGER"); + + b.Property("SeasonNumber") + .HasColumnType("INTEGER"); + + b.Property("TvDbId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("SonarrEpisodeCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.HasOne("Ombi.Store.Entities.EmbyContent", "Series") + .WithMany("Episodes") + .HasForeignKey("ParentId") + .HasPrincipalKey("EmbyId"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinEpisode", b => + { + b.HasOne("Ombi.Store.Entities.JellyfinContent", "Series") + .WithMany("Episodes") + .HasForeignKey("ParentId") + .HasPrincipalKey("JellyfinId"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.HasOne("Ombi.Store.Entities.PlexServerContent", "Series") + .WithMany("Episodes") + .HasForeignKey("GrandparentKey") + .HasPrincipalKey("Key") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.HasOne("Ombi.Store.Entities.PlexServerContent", null) + .WithMany("Seasons") + .HasForeignKey("PlexServerContentId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b => + { + b.Navigation("Episodes"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.JellyfinContent", b => + { + b.Navigation("Episodes"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b => + { + b.Navigation("Episodes"); + + b.Navigation("Seasons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/ExternalSqlite/20210615145321_SonarrSyncMovieDbData.cs b/src/Ombi.Store/Migrations/ExternalSqlite/20210615145321_SonarrSyncMovieDbData.cs new file mode 100644 index 000000000..d5d84477a --- /dev/null +++ b/src/Ombi.Store/Migrations/ExternalSqlite/20210615145321_SonarrSyncMovieDbData.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Ombi.Store.Migrations.ExternalSqlite +{ + public partial class SonarrSyncMovieDbData : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "MovieDbId", + table: "SonarrEpisodeCache", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TheMovieDbId", + table: "SonarrCache", + type: "INTEGER", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "MovieDbId", + table: "SonarrEpisodeCache"); + + migrationBuilder.DropColumn( + name: "TheMovieDbId", + table: "SonarrCache"); + } + } +} diff --git a/src/Ombi.Store/Migrations/ExternalSqlite/ExternalSqliteContextModelSnapshot.cs b/src/Ombi.Store/Migrations/ExternalSqlite/ExternalSqliteContextModelSnapshot.cs index d8378c814..00d4f44f4 100644 --- a/src/Ombi.Store/Migrations/ExternalSqlite/ExternalSqliteContextModelSnapshot.cs +++ b/src/Ombi.Store/Migrations/ExternalSqlite/ExternalSqliteContextModelSnapshot.cs @@ -412,6 +412,9 @@ namespace Ombi.Store.Migrations.ExternalSqlite .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); + b.Property("TheMovieDbId") + .HasColumnType("INTEGER"); + b.Property("TvDbId") .HasColumnType("INTEGER"); @@ -432,6 +435,9 @@ namespace Ombi.Store.Migrations.ExternalSqlite b.Property("HasFile") .HasColumnType("INTEGER"); + b.Property("MovieDbId") + .HasColumnType("INTEGER"); + b.Property("SeasonNumber") .HasColumnType("INTEGER");