mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Merge pull request #2588 from tidusjar/feature/splitoutsettingsdb
Feature/splitoutsettingsdb
This commit is contained in:
commit
a208fbe581
39 changed files with 1625 additions and 205 deletions
|
@ -26,7 +26,7 @@ namespace Ombi.Api.Notifications
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var id = await _appConfig.Get(ConfigurationTypes.Notification);
|
var id = await _appConfig.GetAsync(ConfigurationTypes.Notification);
|
||||||
var request = new Request(string.Empty, ApiUrl, HttpMethod.Post);
|
var request = new Request(string.Empty, ApiUrl, HttpMethod.Post);
|
||||||
|
|
||||||
var body = new OneSignalNotificationBody
|
var body = new OneSignalNotificationBody
|
||||||
|
|
|
@ -7,12 +7,12 @@ namespace Ombi.Core.Rule.Rules.Request
|
||||||
{
|
{
|
||||||
public class SonarrCacheRequestRule : BaseRequestRule, IRules<BaseRequest>
|
public class SonarrCacheRequestRule : BaseRequestRule, IRules<BaseRequest>
|
||||||
{
|
{
|
||||||
public SonarrCacheRequestRule(IOmbiContext ctx)
|
public SonarrCacheRequestRule(IExternalContext ctx)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IOmbiContext _ctx;
|
private readonly IExternalContext _ctx;
|
||||||
|
|
||||||
public Task<RuleResult> Execute(BaseRequest obj)
|
public Task<RuleResult> Execute(BaseRequest obj)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,12 +34,12 @@ namespace Ombi.Core.Rule.Rules.Search
|
||||||
{
|
{
|
||||||
public class SonarrCacheSearchRule : BaseSearchRule, IRules<SearchViewModel>
|
public class SonarrCacheSearchRule : BaseSearchRule, IRules<SearchViewModel>
|
||||||
{
|
{
|
||||||
public SonarrCacheSearchRule(IOmbiContext ctx)
|
public SonarrCacheSearchRule(IExternalContext ctx)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IOmbiContext _ctx;
|
private readonly IExternalContext _ctx;
|
||||||
|
|
||||||
public Task<RuleResult> Execute(SearchViewModel obj)
|
public Task<RuleResult> Execute(SearchViewModel obj)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,12 +10,12 @@ namespace Ombi.Core.Rule.Rules
|
||||||
{
|
{
|
||||||
public class SonarrCacheRule
|
public class SonarrCacheRule
|
||||||
{
|
{
|
||||||
public SonarrCacheRule(IOmbiContext ctx)
|
public SonarrCacheRule(IExternalContext ctx)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IOmbiContext _ctx;
|
private readonly IExternalContext _ctx;
|
||||||
|
|
||||||
public async Task<RuleResult> Execute(BaseRequest obj)
|
public async Task<RuleResult> Execute(BaseRequest obj)
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,8 +129,12 @@ namespace Ombi.DependencyInjection
|
||||||
|
|
||||||
public static void RegisterStore(this IServiceCollection services) {
|
public static void RegisterStore(this IServiceCollection services) {
|
||||||
services.AddEntityFrameworkSqlite().AddDbContext<OmbiContext>();
|
services.AddEntityFrameworkSqlite().AddDbContext<OmbiContext>();
|
||||||
|
services.AddEntityFrameworkSqlite().AddDbContext<SettingsContext>();
|
||||||
|
services.AddEntityFrameworkSqlite().AddDbContext<ExternalContext>();
|
||||||
|
|
||||||
services.AddScoped<IOmbiContext, OmbiContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6
|
services.AddScoped<IOmbiContext, OmbiContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6
|
||||||
|
services.AddScoped<ISettingsContext, SettingsContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6
|
||||||
|
services.AddScoped<IExternalContext, ExternalContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6
|
||||||
services.AddTransient<ISettingsRepository, SettingsJsonRepository>();
|
services.AddTransient<ISettingsRepository, SettingsJsonRepository>();
|
||||||
services.AddTransient<ISettingsResolver, SettingsResolver>();
|
services.AddTransient<ISettingsResolver, SettingsResolver>();
|
||||||
services.AddTransient<IPlexContentRepository, PlexServerContentRepository>();
|
services.AddTransient<IPlexContentRepository, PlexServerContentRepository>();
|
||||||
|
@ -145,6 +149,7 @@ namespace Ombi.DependencyInjection
|
||||||
services.AddTransient<ITokenRepository, TokenRepository>();
|
services.AddTransient<ITokenRepository, TokenRepository>();
|
||||||
services.AddTransient(typeof(ISettingsService<>), typeof(SettingsService<>));
|
services.AddTransient(typeof(ISettingsService<>), typeof(SettingsService<>));
|
||||||
services.AddTransient(typeof(IRepository<>), typeof(Repository<>));
|
services.AddTransient(typeof(IRepository<>), typeof(Repository<>));
|
||||||
|
services.AddTransient(typeof(IExternalRepository<>), typeof(ExternalRepository<>));
|
||||||
}
|
}
|
||||||
public static void RegisterServices(this IServiceCollection services)
|
public static void RegisterServices(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace Ombi.Schedule.Jobs.Couchpotato
|
||||||
public class CouchPotatoSync : ICouchPotatoSync
|
public class CouchPotatoSync : ICouchPotatoSync
|
||||||
{
|
{
|
||||||
public CouchPotatoSync(ISettingsService<CouchPotatoSettings> cpSettings,
|
public CouchPotatoSync(ISettingsService<CouchPotatoSettings> cpSettings,
|
||||||
ICouchPotatoApi api, ILogger<CouchPotatoSync> log, IOmbiContext ctx)
|
ICouchPotatoApi api, ILogger<CouchPotatoSync> log, IExternalContext ctx)
|
||||||
{
|
{
|
||||||
_settings = cpSettings;
|
_settings = cpSettings;
|
||||||
_api = api;
|
_api = api;
|
||||||
|
@ -54,7 +54,7 @@ namespace Ombi.Schedule.Jobs.Couchpotato
|
||||||
private readonly ISettingsService<CouchPotatoSettings> _settings;
|
private readonly ISettingsService<CouchPotatoSettings> _settings;
|
||||||
private readonly ICouchPotatoApi _api;
|
private readonly ICouchPotatoApi _api;
|
||||||
private readonly ILogger<CouchPotatoSync> _log;
|
private readonly ILogger<CouchPotatoSync> _log;
|
||||||
private readonly IOmbiContext _ctx;
|
private readonly IExternalContext _ctx;
|
||||||
|
|
||||||
public async Task Start()
|
public async Task Start()
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
{
|
{
|
||||||
public class LidarrAlbumSync : ILidarrAlbumSync
|
public class LidarrAlbumSync : ILidarrAlbumSync
|
||||||
{
|
{
|
||||||
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, IOmbiContext ctx,
|
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, IExternalContext ctx,
|
||||||
IBackgroundJobClient job, ILidarrAvailabilityChecker availability)
|
IBackgroundJobClient job, ILidarrAvailabilityChecker availability)
|
||||||
{
|
{
|
||||||
_lidarrSettings = lidarr;
|
_lidarrSettings = lidarr;
|
||||||
|
@ -35,7 +35,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
|
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
|
||||||
private readonly ILidarrApi _lidarrApi;
|
private readonly ILidarrApi _lidarrApi;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOmbiContext _ctx;
|
private readonly IExternalContext _ctx;
|
||||||
private readonly IBackgroundJobClient _job;
|
private readonly IBackgroundJobClient _job;
|
||||||
private readonly ILidarrAvailabilityChecker _availability;
|
private readonly ILidarrAvailabilityChecker _availability;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
{
|
{
|
||||||
public class LidarrArtistSync : ILidarrArtistSync
|
public class LidarrArtistSync : ILidarrArtistSync
|
||||||
{
|
{
|
||||||
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, IOmbiContext ctx,
|
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, IExternalContext ctx,
|
||||||
IBackgroundJobClient background, ILidarrAlbumSync album)
|
IBackgroundJobClient background, ILidarrAlbumSync album)
|
||||||
{
|
{
|
||||||
_lidarrSettings = lidarr;
|
_lidarrSettings = lidarr;
|
||||||
|
@ -35,7 +35,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
|
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
|
||||||
private readonly ILidarrApi _lidarrApi;
|
private readonly ILidarrApi _lidarrApi;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOmbiContext _ctx;
|
private readonly IExternalContext _ctx;
|
||||||
private readonly IBackgroundJobClient _job;
|
private readonly IBackgroundJobClient _job;
|
||||||
private readonly ILidarrAlbumSync _albumSync;
|
private readonly ILidarrAlbumSync _albumSync;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
public class OmbiAutomaticUpdater : IOmbiAutomaticUpdater
|
public class OmbiAutomaticUpdater : IOmbiAutomaticUpdater
|
||||||
{
|
{
|
||||||
public OmbiAutomaticUpdater(ILogger<OmbiAutomaticUpdater> log, IChangeLogProcessor service,
|
public OmbiAutomaticUpdater(ILogger<OmbiAutomaticUpdater> log, IChangeLogProcessor service,
|
||||||
ISettingsService<UpdateSettings> s, IProcessProvider proc, IRepository<ApplicationConfiguration> appConfig)
|
ISettingsService<UpdateSettings> s, IProcessProvider proc, IApplicationConfigRepository appConfig)
|
||||||
{
|
{
|
||||||
Logger = log;
|
Logger = log;
|
||||||
Processor = service;
|
Processor = service;
|
||||||
|
@ -48,7 +48,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
private ISettingsService<UpdateSettings> Settings { get; }
|
private ISettingsService<UpdateSettings> Settings { get; }
|
||||||
private readonly IProcessProvider _processProvider;
|
private readonly IProcessProvider _processProvider;
|
||||||
private static PerformContext Ctx { get; set; }
|
private static PerformContext Ctx { get; set; }
|
||||||
private readonly IRepository<ApplicationConfiguration> _appConfig;
|
private readonly IApplicationConfigRepository _appConfig;
|
||||||
|
|
||||||
public string[] GetVersion()
|
public string[] GetVersion()
|
||||||
{
|
{
|
||||||
|
@ -252,9 +252,8 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
|
|
||||||
private string GetArgs(UpdateSettings settings)
|
private string GetArgs(UpdateSettings settings)
|
||||||
{
|
{
|
||||||
var config = _appConfig.GetAll();
|
var url = _appConfig.Get(ConfigurationTypes.Url);
|
||||||
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
|
var storage = _appConfig.Get(ConfigurationTypes.StoragePath);
|
||||||
var storage = config.FirstOrDefault(x => x.Type == ConfigurationTypes.StoragePath);
|
|
||||||
|
|
||||||
var currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
var currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||||
var processName = (settings.ProcessName.HasValue() ? settings.ProcessName : "Ombi");
|
var processName = (settings.ProcessName.HasValue() ? settings.ProcessName : "Ombi");
|
||||||
|
@ -345,7 +344,6 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
|
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
_appConfig?.Dispose();
|
|
||||||
Settings?.Dispose();
|
Settings?.Dispose();
|
||||||
}
|
}
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Ombi.Schedule.Jobs.Radarr
|
||||||
{
|
{
|
||||||
public class RadarrSync : IRadarrSync
|
public class RadarrSync : IRadarrSync
|
||||||
{
|
{
|
||||||
public RadarrSync(ISettingsService<RadarrSettings> radarr, IRadarrApi radarrApi, ILogger<RadarrSync> log, IOmbiContext ctx)
|
public RadarrSync(ISettingsService<RadarrSettings> radarr, IRadarrApi radarrApi, ILogger<RadarrSync> log, IExternalContext ctx)
|
||||||
{
|
{
|
||||||
RadarrSettings = radarr;
|
RadarrSettings = radarr;
|
||||||
RadarrApi = radarrApi;
|
RadarrApi = radarrApi;
|
||||||
|
@ -28,7 +28,7 @@ namespace Ombi.Schedule.Jobs.Radarr
|
||||||
private ISettingsService<RadarrSettings> RadarrSettings { get; }
|
private ISettingsService<RadarrSettings> RadarrSettings { get; }
|
||||||
private IRadarrApi RadarrApi { get; }
|
private IRadarrApi RadarrApi { get; }
|
||||||
private ILogger<RadarrSync> Logger { get; }
|
private ILogger<RadarrSync> Logger { get; }
|
||||||
private readonly IOmbiContext _ctx;
|
private readonly IExternalContext _ctx;
|
||||||
|
|
||||||
private static readonly SemaphoreSlim SemaphoreSlim = new SemaphoreSlim(1, 1);
|
private static readonly SemaphoreSlim SemaphoreSlim = new SemaphoreSlim(1, 1);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
@ -17,7 +16,7 @@ namespace Ombi.Schedule.Jobs.SickRage
|
||||||
{
|
{
|
||||||
public class SickRageSync : ISickRageSync
|
public class SickRageSync : ISickRageSync
|
||||||
{
|
{
|
||||||
public SickRageSync(ISettingsService<SickRageSettings> s, ISickRageApi api, ILogger<SickRageSync> l, IOmbiContext ctx)
|
public SickRageSync(ISettingsService<SickRageSettings> s, ISickRageApi api, ILogger<SickRageSync> l, IExternalContext ctx)
|
||||||
{
|
{
|
||||||
_settings = s;
|
_settings = s;
|
||||||
_api = api;
|
_api = api;
|
||||||
|
@ -29,7 +28,7 @@ namespace Ombi.Schedule.Jobs.SickRage
|
||||||
private readonly ISettingsService<SickRageSettings> _settings;
|
private readonly ISettingsService<SickRageSettings> _settings;
|
||||||
private readonly ISickRageApi _api;
|
private readonly ISickRageApi _api;
|
||||||
private readonly ILogger<SickRageSync> _log;
|
private readonly ILogger<SickRageSync> _log;
|
||||||
private readonly IOmbiContext _ctx;
|
private readonly IExternalContext _ctx;
|
||||||
|
|
||||||
public async Task Start()
|
public async Task Start()
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
|
||||||
{
|
{
|
||||||
public class SonarrSync : ISonarrSync
|
public class SonarrSync : ISonarrSync
|
||||||
{
|
{
|
||||||
public SonarrSync(ISettingsService<SonarrSettings> s, ISonarrApi api, ILogger<SonarrSync> l, IOmbiContext ctx)
|
public SonarrSync(ISettingsService<SonarrSettings> s, ISonarrApi api, ILogger<SonarrSync> l, IExternalContext ctx)
|
||||||
{
|
{
|
||||||
_settings = s;
|
_settings = s;
|
||||||
_api = api;
|
_api = api;
|
||||||
|
@ -31,7 +31,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
|
||||||
private readonly ISettingsService<SonarrSettings> _settings;
|
private readonly ISettingsService<SonarrSettings> _settings;
|
||||||
private readonly ISonarrApi _api;
|
private readonly ISonarrApi _api;
|
||||||
private readonly ILogger<SonarrSync> _log;
|
private readonly ILogger<SonarrSync> _log;
|
||||||
private readonly IOmbiContext _ctx;
|
private readonly IExternalContext _ctx;
|
||||||
|
|
||||||
public async Task Start()
|
public async Task Start()
|
||||||
{
|
{
|
||||||
|
|
68
src/Ombi.Store/Context/ExternalContext.cs
Normal file
68
src/Ombi.Store/Context/ExternalContext.cs
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Ombi.Helpers;
|
||||||
|
using Ombi.Store.Entities;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Context
|
||||||
|
{
|
||||||
|
public sealed class ExternalContext : DbContext, IExternalContext
|
||||||
|
{
|
||||||
|
private static bool _created;
|
||||||
|
public ExternalContext()
|
||||||
|
{
|
||||||
|
if (_created) return;
|
||||||
|
|
||||||
|
_created = true;
|
||||||
|
Database.Migrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbSet<PlexServerContent> PlexServerContent { get; set; }
|
||||||
|
public DbSet<PlexSeasonsContent> PlexSeasonsContent { get; set; }
|
||||||
|
public DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||||
|
public DbSet<RadarrCache> RadarrCache { get; set; }
|
||||||
|
public DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
||||||
|
public DbSet<EmbyContent> EmbyContent { get; set; }
|
||||||
|
public DbSet<EmbyEpisode> EmbyEpisode { get; set; }
|
||||||
|
|
||||||
|
public DbSet<SonarrCache> SonarrCache { get; set; }
|
||||||
|
public DbSet<LidarrArtistCache> LidarrArtistCache { get; set; }
|
||||||
|
public DbSet<LidarrAlbumCache> LidarrAlbumCache { get; set; }
|
||||||
|
public DbSet<SonarrEpisodeCache> SonarrEpisodeCache { get; set; }
|
||||||
|
public DbSet<SickRageCache> SickRageCache { get; set; }
|
||||||
|
public DbSet<SickRageEpisodeCache> SickRageEpisodeCache { get; set; }
|
||||||
|
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
var i = StoragePathSingleton.Instance;
|
||||||
|
if (string.IsNullOrEmpty(i.StoragePath))
|
||||||
|
{
|
||||||
|
i.StoragePath = string.Empty;
|
||||||
|
}
|
||||||
|
optionsBuilder.UseSqlite($"Data Source={Path.Combine(i.StoragePath, "OmbiExternal.db")}");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
|
{
|
||||||
|
builder.Entity<PlexServerContent>().HasMany(x => x.Episodes)
|
||||||
|
.WithOne(x => x.Series)
|
||||||
|
.HasPrincipalKey(x => x.Key)
|
||||||
|
.HasForeignKey(x => x.GrandparentKey);
|
||||||
|
|
||||||
|
builder.Entity<EmbyEpisode>()
|
||||||
|
.HasOne(p => p.Series)
|
||||||
|
.WithMany(b => b.Episodes)
|
||||||
|
.HasPrincipalKey(x => x.EmbyId)
|
||||||
|
.HasForeignKey(p => p.ParentId);
|
||||||
|
|
||||||
|
base.OnModelCreating(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Seed()
|
||||||
|
{
|
||||||
|
// VACUUM;
|
||||||
|
Database.ExecuteSqlCommand("VACUUM;");
|
||||||
|
SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
src/Ombi.Store/Context/IDbContext.cs
Normal file
22
src/Ombi.Store/Context/IDbContext.cs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Context
|
||||||
|
{
|
||||||
|
public interface IDbContext : IDisposable
|
||||||
|
{
|
||||||
|
EntityEntry Update(object entity);
|
||||||
|
EntityEntry<TEntity> Update<TEntity>(TEntity entity) where TEntity : class;
|
||||||
|
int SaveChanges();
|
||||||
|
void Seed();
|
||||||
|
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
|
||||||
|
DatabaseFacade Database { get; }
|
||||||
|
EntityEntry<T> Entry<T>(T entry) where T : class;
|
||||||
|
EntityEntry<TEntity> Attach<TEntity>(TEntity entity) where TEntity : class;
|
||||||
|
DbSet<TEntity> Set<TEntity>() where TEntity : class;
|
||||||
|
}
|
||||||
|
}
|
21
src/Ombi.Store/Context/IExternalContext.cs
Normal file
21
src/Ombi.Store/Context/IExternalContext.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Ombi.Store.Entities;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Context
|
||||||
|
{
|
||||||
|
public interface IExternalContext : IDbContext
|
||||||
|
{
|
||||||
|
DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
||||||
|
DbSet<EmbyContent> EmbyContent { get; set; }
|
||||||
|
DbSet<EmbyEpisode> EmbyEpisode { get; set; }
|
||||||
|
DbSet<LidarrAlbumCache> LidarrAlbumCache { get; set; }
|
||||||
|
DbSet<LidarrArtistCache> LidarrArtistCache { get; set; }
|
||||||
|
DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||||
|
DbSet<PlexServerContent> PlexServerContent { get; set; }
|
||||||
|
DbSet<RadarrCache> RadarrCache { get; set; }
|
||||||
|
DbSet<SickRageCache> SickRageCache { get; set; }
|
||||||
|
DbSet<SickRageEpisodeCache> SickRageEpisodeCache { get; set; }
|
||||||
|
DbSet<SonarrCache> SonarrCache { get; set; }
|
||||||
|
DbSet<SonarrEpisodeCache> SonarrEpisodeCache { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,20 +9,15 @@ using Ombi.Store.Entities.Requests;
|
||||||
|
|
||||||
namespace Ombi.Store.Context
|
namespace Ombi.Store.Context
|
||||||
{
|
{
|
||||||
public interface IOmbiContext : IDisposable
|
public interface IOmbiContext : IDbContext
|
||||||
{
|
{
|
||||||
int SaveChanges();
|
|
||||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
|
//DbSet<PlexServerContent> PlexServerContent { get; set; }
|
||||||
|
//DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||||
DbSet<GlobalSettings> Settings { get; set; }
|
DbSet<GlobalSettings> Settings { get; set; }
|
||||||
DbSet<PlexServerContent> PlexServerContent { get; set; }
|
//DbSet<RadarrCache> RadarrCache { get; set; }
|
||||||
DbSet<PlexEpisode> PlexEpisode { get; set; }
|
//DbSet<EmbyContent> EmbyContent { get; set; }
|
||||||
DbSet<RadarrCache> RadarrCache { get; set; }
|
//DbSet<EmbyEpisode> EmbyEpisode { get; set; }
|
||||||
DbSet<EmbyContent> EmbyContent { get; set; }
|
|
||||||
DbSet<EmbyEpisode> EmbyEpisode { get; set; }
|
|
||||||
DatabaseFacade Database { get; }
|
|
||||||
EntityEntry<T> Entry<T>(T entry) where T : class;
|
|
||||||
EntityEntry<TEntity> Attach<TEntity>(TEntity entity) where TEntity : class;
|
|
||||||
DbSet<TEntity> Set<TEntity>() where TEntity : class;
|
|
||||||
DbSet<NotificationTemplates> NotificationTemplates { get; set; }
|
DbSet<NotificationTemplates> NotificationTemplates { get; set; }
|
||||||
DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||||
DbSet<Votes> Votes { get; set; }
|
DbSet<Votes> Votes { get; set; }
|
||||||
|
@ -36,14 +31,12 @@ namespace Ombi.Store.Context
|
||||||
DbSet<IssueCategory> IssueCategories { get; set; }
|
DbSet<IssueCategory> IssueCategories { get; set; }
|
||||||
DbSet<Tokens> Tokens { get; set; }
|
DbSet<Tokens> Tokens { get; set; }
|
||||||
DbSet<SonarrCache> SonarrCache { get; set; }
|
DbSet<SonarrCache> SonarrCache { get; set; }
|
||||||
DbSet<SonarrEpisodeCache> SonarrEpisodeCache { get; set; }
|
//DbSet<SonarrEpisodeCache> SonarrEpisodeCache { get; set; }
|
||||||
EntityEntry Update(object entity);
|
//DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
||||||
EntityEntry<TEntity> Update<TEntity>(TEntity entity) where TEntity : class;
|
//DbSet<SickRageCache> SickRageCache { get; set; }
|
||||||
DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
//DbSet<LidarrArtistCache> LidarrArtistCache { get; set; }
|
||||||
DbSet<SickRageCache> SickRageCache { get; set; }
|
//DbSet<LidarrAlbumCache> LidarrAlbumCache { get; set; }
|
||||||
DbSet<LidarrArtistCache> LidarrArtistCache { get; set; }
|
//DbSet<SickRageEpisodeCache> SickRageEpisodeCache { get; set; }
|
||||||
DbSet<LidarrAlbumCache> LidarrAlbumCache { get; set; }
|
|
||||||
DbSet<SickRageEpisodeCache> SickRageEpisodeCache { get; set; }
|
|
||||||
DbSet<RequestLog> RequestLogs { get; set; }
|
DbSet<RequestLog> RequestLogs { get; set; }
|
||||||
DbSet<RecentlyAddedLog> RecentlyAddedLogs { get; set; }
|
DbSet<RecentlyAddedLog> RecentlyAddedLogs { get; set; }
|
||||||
DbSet<RequestSubscription> RequestSubscription { get; set; }
|
DbSet<RequestSubscription> RequestSubscription { get; set; }
|
||||||
|
|
11
src/Ombi.Store/Context/ISettingsContext.cs
Normal file
11
src/Ombi.Store/Context/ISettingsContext.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Ombi.Store.Entities;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Context
|
||||||
|
{
|
||||||
|
public interface ISettingsContext : IDbContext
|
||||||
|
{
|
||||||
|
DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||||
|
DbSet<GlobalSettings> Settings { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,9 +22,11 @@ namespace Ombi.Store.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbSet<NotificationTemplates> NotificationTemplates { get; set; }
|
public DbSet<NotificationTemplates> NotificationTemplates { get; set; }
|
||||||
public DbSet<GlobalSettings> Settings { get; set; }
|
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||||
public DbSet<PlexServerContent> PlexServerContent { get; set; }
|
public DbSet<PlexServerContent> PlexServerContent { get; set; }
|
||||||
|
public DbSet<PlexSeasonsContent> PlexSeasonsContent { get; set; }
|
||||||
public DbSet<PlexEpisode> PlexEpisode { get; set; }
|
public DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||||
|
public DbSet<GlobalSettings> Settings { get; set; }
|
||||||
public DbSet<RadarrCache> RadarrCache { get; set; }
|
public DbSet<RadarrCache> RadarrCache { get; set; }
|
||||||
public DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
public DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
||||||
public DbSet<EmbyContent> EmbyContent { get; set; }
|
public DbSet<EmbyContent> EmbyContent { get; set; }
|
||||||
|
@ -54,7 +56,6 @@ namespace Ombi.Store.Context
|
||||||
public DbSet<RequestSubscription> RequestSubscription { get; set; }
|
public DbSet<RequestSubscription> RequestSubscription { get; set; }
|
||||||
public DbSet<UserNotificationPreferences> UserNotificationPreferences { get; set; }
|
public DbSet<UserNotificationPreferences> UserNotificationPreferences { get; set; }
|
||||||
public DbSet<UserQualityProfiles> UserQualityProfileses { get; set; }
|
public DbSet<UserQualityProfiles> UserQualityProfileses { get; set; }
|
||||||
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
|
@ -85,39 +86,6 @@ namespace Ombi.Store.Context
|
||||||
|
|
||||||
public void Seed()
|
public void Seed()
|
||||||
{
|
{
|
||||||
|
|
||||||
// Add the tokens
|
|
||||||
var fanArt = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
|
||||||
if (fanArt == null)
|
|
||||||
{
|
|
||||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
|
||||||
{
|
|
||||||
Type = ConfigurationTypes.FanartTv,
|
|
||||||
Value = "4b6d983efa54d8f45c68432521335f15"
|
|
||||||
});
|
|
||||||
SaveChanges();
|
|
||||||
}
|
|
||||||
var movieDb = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
|
||||||
if (movieDb == null)
|
|
||||||
{
|
|
||||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
|
||||||
{
|
|
||||||
Type = ConfigurationTypes.TheMovieDb,
|
|
||||||
Value = "b8eabaf5608b88d0298aa189dd90bf00"
|
|
||||||
});
|
|
||||||
SaveChanges();
|
|
||||||
}
|
|
||||||
var notification = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Notification);
|
|
||||||
if (notification == null)
|
|
||||||
{
|
|
||||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
|
||||||
{
|
|
||||||
Type = ConfigurationTypes.Notification,
|
|
||||||
Value = "4f0260c4-9c3d-41ab-8d68-27cb5a593f0e"
|
|
||||||
});
|
|
||||||
SaveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
// VACUUM;
|
// VACUUM;
|
||||||
Database.ExecuteSqlCommand("VACUUM;");
|
Database.ExecuteSqlCommand("VACUUM;");
|
||||||
|
|
||||||
|
|
70
src/Ombi.Store/Context/SettingsContext.cs
Normal file
70
src/Ombi.Store/Context/SettingsContext.cs
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Ombi.Helpers;
|
||||||
|
using Ombi.Store.Entities;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Context
|
||||||
|
{
|
||||||
|
public sealed class SettingsContext : DbContext, ISettingsContext
|
||||||
|
{
|
||||||
|
private static bool _created;
|
||||||
|
public SettingsContext()
|
||||||
|
{
|
||||||
|
if (_created) return;
|
||||||
|
|
||||||
|
_created = true;
|
||||||
|
Database.Migrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbSet<GlobalSettings> Settings { get; set; }
|
||||||
|
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||||
|
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
var i = StoragePathSingleton.Instance;
|
||||||
|
if (string.IsNullOrEmpty(i.StoragePath))
|
||||||
|
{
|
||||||
|
i.StoragePath = string.Empty;
|
||||||
|
}
|
||||||
|
optionsBuilder.UseSqlite($"Data Source={Path.Combine(i.StoragePath, "OmbiSettings.db")}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Seed()
|
||||||
|
{
|
||||||
|
// Add the tokens
|
||||||
|
var fanArt = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||||
|
if (fanArt == null)
|
||||||
|
{
|
||||||
|
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||||
|
{
|
||||||
|
Type = ConfigurationTypes.FanartTv,
|
||||||
|
Value = "4b6d983efa54d8f45c68432521335f15"
|
||||||
|
});
|
||||||
|
SaveChanges();
|
||||||
|
}
|
||||||
|
var movieDb = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||||
|
if (movieDb == null)
|
||||||
|
{
|
||||||
|
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||||
|
{
|
||||||
|
Type = ConfigurationTypes.TheMovieDb,
|
||||||
|
Value = "b8eabaf5608b88d0298aa189dd90bf00"
|
||||||
|
});
|
||||||
|
SaveChanges();
|
||||||
|
}
|
||||||
|
var notification = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Notification);
|
||||||
|
if (notification == null)
|
||||||
|
{
|
||||||
|
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||||
|
{
|
||||||
|
Type = ConfigurationTypes.Notification,
|
||||||
|
Value = "4f0260c4-9c3d-41ab-8d68-27cb5a593f0e"
|
||||||
|
});
|
||||||
|
SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,12 +43,8 @@ namespace Ombi.Store.Entities
|
||||||
|
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Only used for TV Shows
|
|
||||||
/// </summary>
|
|
||||||
public virtual ICollection<PlexSeasonsContent> Seasons { get; set; }
|
|
||||||
|
|
||||||
public ICollection<PlexEpisode> Episodes { get; set; }
|
public ICollection<PlexEpisode> Episodes { get; set; }
|
||||||
|
public ICollection<PlexSeasonsContent> Seasons { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plex's internal ID for this item
|
/// Plex's internal ID for this item
|
||||||
|
|
312
src/Ombi.Store/Migrations/External/20181004134907_Inital.Designer.cs
generated
vendored
Normal file
312
src/Ombi.Store/Migrations/External/20181004134907_Inital.Designer.cs
generated
vendored
Normal file
|
@ -0,0 +1,312 @@
|
||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Ombi.Store.Context;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Migrations.External
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ExternalContext))]
|
||||||
|
[Migration("20181004134907_Inital")]
|
||||||
|
partial class Inital
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065");
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("TheMovieDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("CouchPotatoCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<DateTime>("AddedAt");
|
||||||
|
|
||||||
|
b.Property<string>("EmbyId")
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Property<string>("ImdbId");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderId");
|
||||||
|
|
||||||
|
b.Property<string>("TheMovieDbId");
|
||||||
|
|
||||||
|
b.Property<string>("Title");
|
||||||
|
|
||||||
|
b.Property<string>("TvDbId");
|
||||||
|
|
||||||
|
b.Property<int>("Type");
|
||||||
|
|
||||||
|
b.Property<string>("Url");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("EmbyContent");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<DateTime>("AddedAt");
|
||||||
|
|
||||||
|
b.Property<string>("EmbyId");
|
||||||
|
|
||||||
|
b.Property<int>("EpisodeNumber");
|
||||||
|
|
||||||
|
b.Property<string>("ImdbId");
|
||||||
|
|
||||||
|
b.Property<string>("ParentId");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderId");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonNumber");
|
||||||
|
|
||||||
|
b.Property<string>("TheMovieDbId");
|
||||||
|
|
||||||
|
b.Property<string>("Title");
|
||||||
|
|
||||||
|
b.Property<string>("TvDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ParentId");
|
||||||
|
|
||||||
|
b.ToTable("EmbyEpisode");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.LidarrAlbumCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<DateTime>("AddedAt");
|
||||||
|
|
||||||
|
b.Property<int>("ArtistId");
|
||||||
|
|
||||||
|
b.Property<string>("ForeignAlbumId");
|
||||||
|
|
||||||
|
b.Property<bool>("Monitored");
|
||||||
|
|
||||||
|
b.Property<decimal>("PercentOfTracks");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ReleaseDate");
|
||||||
|
|
||||||
|
b.Property<string>("Title");
|
||||||
|
|
||||||
|
b.Property<int>("TrackCount");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("LidarrAlbumCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.LidarrArtistCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("ArtistId");
|
||||||
|
|
||||||
|
b.Property<string>("ArtistName");
|
||||||
|
|
||||||
|
b.Property<string>("ForeignArtistId");
|
||||||
|
|
||||||
|
b.Property<bool>("Monitored");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("LidarrArtistCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("EpisodeNumber");
|
||||||
|
|
||||||
|
b.Property<int>("GrandparentKey");
|
||||||
|
|
||||||
|
b.Property<int>("Key");
|
||||||
|
|
||||||
|
b.Property<int>("ParentKey");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonNumber");
|
||||||
|
|
||||||
|
b.Property<string>("Title");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("GrandparentKey");
|
||||||
|
|
||||||
|
b.ToTable("PlexEpisode");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("ParentKey");
|
||||||
|
|
||||||
|
b.Property<int>("PlexContentId");
|
||||||
|
|
||||||
|
b.Property<int?>("PlexServerContentId");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonKey");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonNumber");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PlexServerContentId");
|
||||||
|
|
||||||
|
b.ToTable("PlexSeasonsContent");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<DateTime>("AddedAt");
|
||||||
|
|
||||||
|
b.Property<string>("ImdbId");
|
||||||
|
|
||||||
|
b.Property<int>("Key");
|
||||||
|
|
||||||
|
b.Property<string>("Quality");
|
||||||
|
|
||||||
|
b.Property<string>("ReleaseYear");
|
||||||
|
|
||||||
|
b.Property<string>("TheMovieDbId");
|
||||||
|
|
||||||
|
b.Property<string>("Title");
|
||||||
|
|
||||||
|
b.Property<string>("TvDbId");
|
||||||
|
|
||||||
|
b.Property<int>("Type");
|
||||||
|
|
||||||
|
b.Property<string>("Url");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("PlexServerContent");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.RadarrCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<bool>("HasFile");
|
||||||
|
|
||||||
|
b.Property<int>("TheMovieDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("RadarrCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.SickRageCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("TvDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("SickRageCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.SickRageEpisodeCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("EpisodeNumber");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonNumber");
|
||||||
|
|
||||||
|
b.Property<int>("TvDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("SickRageEpisodeCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.SonarrCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("TvDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("SonarrCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.SonarrEpisodeCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("EpisodeNumber");
|
||||||
|
|
||||||
|
b.Property<bool>("HasFile");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonNumber");
|
||||||
|
|
||||||
|
b.Property<int>("TvDbId");
|
||||||
|
|
||||||
|
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");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Ombi.Store.Entities.PlexServerContent", "Series")
|
||||||
|
.WithMany("Episodes")
|
||||||
|
.HasForeignKey("GrandparentKey")
|
||||||
|
.HasPrincipalKey("Key")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Ombi.Store.Entities.PlexServerContent")
|
||||||
|
.WithMany("Seasons")
|
||||||
|
.HasForeignKey("PlexServerContentId");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
308
src/Ombi.Store/Migrations/External/20181004134907_Inital.cs
vendored
Normal file
308
src/Ombi.Store/Migrations/External/20181004134907_Inital.cs
vendored
Normal file
|
@ -0,0 +1,308 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Migrations.External
|
||||||
|
{
|
||||||
|
public partial class Inital : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "CouchPotatoCache",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
TheMovieDbId = table.Column<int>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_CouchPotatoCache", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "EmbyContent",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Title = table.Column<string>(nullable: true),
|
||||||
|
ProviderId = table.Column<string>(nullable: true),
|
||||||
|
EmbyId = table.Column<string>(nullable: false),
|
||||||
|
Type = table.Column<int>(nullable: false),
|
||||||
|
AddedAt = table.Column<DateTime>(nullable: false),
|
||||||
|
ImdbId = table.Column<string>(nullable: true),
|
||||||
|
TheMovieDbId = table.Column<string>(nullable: true),
|
||||||
|
TvDbId = table.Column<string>(nullable: true),
|
||||||
|
Url = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_EmbyContent", x => x.Id);
|
||||||
|
table.UniqueConstraint("AK_EmbyContent_EmbyId", x => x.EmbyId);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "LidarrAlbumCache",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
ArtistId = table.Column<int>(nullable: false),
|
||||||
|
ForeignAlbumId = table.Column<string>(nullable: true),
|
||||||
|
TrackCount = table.Column<int>(nullable: false),
|
||||||
|
ReleaseDate = table.Column<DateTime>(nullable: false),
|
||||||
|
Monitored = table.Column<bool>(nullable: false),
|
||||||
|
Title = table.Column<string>(nullable: true),
|
||||||
|
PercentOfTracks = table.Column<decimal>(nullable: false),
|
||||||
|
AddedAt = table.Column<DateTime>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_LidarrAlbumCache", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "LidarrArtistCache",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
ArtistId = table.Column<int>(nullable: false),
|
||||||
|
ArtistName = table.Column<string>(nullable: true),
|
||||||
|
ForeignArtistId = table.Column<string>(nullable: true),
|
||||||
|
Monitored = table.Column<bool>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_LidarrArtistCache", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PlexServerContent",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Title = table.Column<string>(nullable: true),
|
||||||
|
ReleaseYear = table.Column<string>(nullable: true),
|
||||||
|
ImdbId = table.Column<string>(nullable: true),
|
||||||
|
TvDbId = table.Column<string>(nullable: true),
|
||||||
|
TheMovieDbId = table.Column<string>(nullable: true),
|
||||||
|
Type = table.Column<int>(nullable: false),
|
||||||
|
Url = table.Column<string>(nullable: true),
|
||||||
|
Key = table.Column<int>(nullable: false),
|
||||||
|
AddedAt = table.Column<DateTime>(nullable: false),
|
||||||
|
Quality = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PlexServerContent", x => x.Id);
|
||||||
|
table.UniqueConstraint("AK_PlexServerContent_Key", x => x.Key);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "RadarrCache",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
TheMovieDbId = table.Column<int>(nullable: false),
|
||||||
|
HasFile = table.Column<bool>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_RadarrCache", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "SickRageCache",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
TvDbId = table.Column<int>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_SickRageCache", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "SickRageEpisodeCache",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
SeasonNumber = table.Column<int>(nullable: false),
|
||||||
|
EpisodeNumber = table.Column<int>(nullable: false),
|
||||||
|
TvDbId = table.Column<int>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_SickRageEpisodeCache", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "SonarrCache",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
TvDbId = table.Column<int>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_SonarrCache", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "SonarrEpisodeCache",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
SeasonNumber = table.Column<int>(nullable: false),
|
||||||
|
EpisodeNumber = table.Column<int>(nullable: false),
|
||||||
|
TvDbId = table.Column<int>(nullable: false),
|
||||||
|
HasFile = table.Column<bool>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_SonarrEpisodeCache", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "EmbyEpisode",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Title = table.Column<string>(nullable: true),
|
||||||
|
EmbyId = table.Column<string>(nullable: true),
|
||||||
|
EpisodeNumber = table.Column<int>(nullable: false),
|
||||||
|
SeasonNumber = table.Column<int>(nullable: false),
|
||||||
|
ParentId = table.Column<string>(nullable: true),
|
||||||
|
ProviderId = table.Column<string>(nullable: true),
|
||||||
|
AddedAt = table.Column<DateTime>(nullable: false),
|
||||||
|
TvDbId = table.Column<string>(nullable: true),
|
||||||
|
ImdbId = table.Column<string>(nullable: true),
|
||||||
|
TheMovieDbId = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_EmbyEpisode", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_EmbyEpisode_EmbyContent_ParentId",
|
||||||
|
column: x => x.ParentId,
|
||||||
|
principalTable: "EmbyContent",
|
||||||
|
principalColumn: "EmbyId",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PlexEpisode",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
EpisodeNumber = table.Column<int>(nullable: false),
|
||||||
|
SeasonNumber = table.Column<int>(nullable: false),
|
||||||
|
Key = table.Column<int>(nullable: false),
|
||||||
|
Title = table.Column<string>(nullable: true),
|
||||||
|
ParentKey = table.Column<int>(nullable: false),
|
||||||
|
GrandparentKey = table.Column<int>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PlexEpisode", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlexEpisode_PlexServerContent_GrandparentKey",
|
||||||
|
column: x => x.GrandparentKey,
|
||||||
|
principalTable: "PlexServerContent",
|
||||||
|
principalColumn: "Key",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PlexSeasonsContent",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
PlexContentId = table.Column<int>(nullable: false),
|
||||||
|
SeasonNumber = table.Column<int>(nullable: false),
|
||||||
|
SeasonKey = table.Column<int>(nullable: false),
|
||||||
|
ParentKey = table.Column<int>(nullable: false),
|
||||||
|
PlexServerContentId = table.Column<int>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PlexSeasonsContent", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlexSeasonsContent_PlexServerContent_PlexServerContentId",
|
||||||
|
column: x => x.PlexServerContentId,
|
||||||
|
principalTable: "PlexServerContent",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_EmbyEpisode_ParentId",
|
||||||
|
table: "EmbyEpisode",
|
||||||
|
column: "ParentId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlexEpisode_GrandparentKey",
|
||||||
|
table: "PlexEpisode",
|
||||||
|
column: "GrandparentKey");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlexSeasonsContent_PlexServerContentId",
|
||||||
|
table: "PlexSeasonsContent",
|
||||||
|
column: "PlexServerContentId");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "CouchPotatoCache");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "EmbyEpisode");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "LidarrAlbumCache");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "LidarrArtistCache");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PlexEpisode");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PlexSeasonsContent");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "RadarrCache");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "SickRageCache");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "SickRageEpisodeCache");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "SonarrCache");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "SonarrEpisodeCache");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "EmbyContent");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PlexServerContent");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
310
src/Ombi.Store/Migrations/External/ExternalContextModelSnapshot.cs
vendored
Normal file
310
src/Ombi.Store/Migrations/External/ExternalContextModelSnapshot.cs
vendored
Normal file
|
@ -0,0 +1,310 @@
|
||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Ombi.Store.Context;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Migrations.External
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ExternalContext))]
|
||||||
|
partial class ExternalContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065");
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("TheMovieDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("CouchPotatoCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<DateTime>("AddedAt");
|
||||||
|
|
||||||
|
b.Property<string>("EmbyId")
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Property<string>("ImdbId");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderId");
|
||||||
|
|
||||||
|
b.Property<string>("TheMovieDbId");
|
||||||
|
|
||||||
|
b.Property<string>("Title");
|
||||||
|
|
||||||
|
b.Property<string>("TvDbId");
|
||||||
|
|
||||||
|
b.Property<int>("Type");
|
||||||
|
|
||||||
|
b.Property<string>("Url");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("EmbyContent");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<DateTime>("AddedAt");
|
||||||
|
|
||||||
|
b.Property<string>("EmbyId");
|
||||||
|
|
||||||
|
b.Property<int>("EpisodeNumber");
|
||||||
|
|
||||||
|
b.Property<string>("ImdbId");
|
||||||
|
|
||||||
|
b.Property<string>("ParentId");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderId");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonNumber");
|
||||||
|
|
||||||
|
b.Property<string>("TheMovieDbId");
|
||||||
|
|
||||||
|
b.Property<string>("Title");
|
||||||
|
|
||||||
|
b.Property<string>("TvDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ParentId");
|
||||||
|
|
||||||
|
b.ToTable("EmbyEpisode");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.LidarrAlbumCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<DateTime>("AddedAt");
|
||||||
|
|
||||||
|
b.Property<int>("ArtistId");
|
||||||
|
|
||||||
|
b.Property<string>("ForeignAlbumId");
|
||||||
|
|
||||||
|
b.Property<bool>("Monitored");
|
||||||
|
|
||||||
|
b.Property<decimal>("PercentOfTracks");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ReleaseDate");
|
||||||
|
|
||||||
|
b.Property<string>("Title");
|
||||||
|
|
||||||
|
b.Property<int>("TrackCount");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("LidarrAlbumCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.LidarrArtistCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("ArtistId");
|
||||||
|
|
||||||
|
b.Property<string>("ArtistName");
|
||||||
|
|
||||||
|
b.Property<string>("ForeignArtistId");
|
||||||
|
|
||||||
|
b.Property<bool>("Monitored");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("LidarrArtistCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("EpisodeNumber");
|
||||||
|
|
||||||
|
b.Property<int>("GrandparentKey");
|
||||||
|
|
||||||
|
b.Property<int>("Key");
|
||||||
|
|
||||||
|
b.Property<int>("ParentKey");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonNumber");
|
||||||
|
|
||||||
|
b.Property<string>("Title");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("GrandparentKey");
|
||||||
|
|
||||||
|
b.ToTable("PlexEpisode");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("ParentKey");
|
||||||
|
|
||||||
|
b.Property<int>("PlexContentId");
|
||||||
|
|
||||||
|
b.Property<int?>("PlexServerContentId");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonKey");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonNumber");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PlexServerContentId");
|
||||||
|
|
||||||
|
b.ToTable("PlexSeasonsContent");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<DateTime>("AddedAt");
|
||||||
|
|
||||||
|
b.Property<string>("ImdbId");
|
||||||
|
|
||||||
|
b.Property<int>("Key");
|
||||||
|
|
||||||
|
b.Property<string>("Quality");
|
||||||
|
|
||||||
|
b.Property<string>("ReleaseYear");
|
||||||
|
|
||||||
|
b.Property<string>("TheMovieDbId");
|
||||||
|
|
||||||
|
b.Property<string>("Title");
|
||||||
|
|
||||||
|
b.Property<string>("TvDbId");
|
||||||
|
|
||||||
|
b.Property<int>("Type");
|
||||||
|
|
||||||
|
b.Property<string>("Url");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("PlexServerContent");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.RadarrCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<bool>("HasFile");
|
||||||
|
|
||||||
|
b.Property<int>("TheMovieDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("RadarrCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.SickRageCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("TvDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("SickRageCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.SickRageEpisodeCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("EpisodeNumber");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonNumber");
|
||||||
|
|
||||||
|
b.Property<int>("TvDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("SickRageEpisodeCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.SonarrCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("TvDbId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("SonarrCache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.SonarrEpisodeCache", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("EpisodeNumber");
|
||||||
|
|
||||||
|
b.Property<bool>("HasFile");
|
||||||
|
|
||||||
|
b.Property<int>("SeasonNumber");
|
||||||
|
|
||||||
|
b.Property<int>("TvDbId");
|
||||||
|
|
||||||
|
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");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Ombi.Store.Entities.PlexServerContent", "Series")
|
||||||
|
.WithMany("Episodes")
|
||||||
|
.HasForeignKey("GrandparentKey")
|
||||||
|
.HasPrincipalKey("Key")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Ombi.Store.Entities.PlexServerContent")
|
||||||
|
.WithMany("Seasons")
|
||||||
|
.HasForeignKey("PlexServerContentId");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.Designer.cs
generated
Normal file
50
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.Designer.cs
generated
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
// <auto-generated />
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Ombi.Store.Context;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Migrations.Settings
|
||||||
|
{
|
||||||
|
[DbContext(typeof(SettingsContext))]
|
||||||
|
[Migration("20181004132516_Inital")]
|
||||||
|
partial class Inital
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065");
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("Type");
|
||||||
|
|
||||||
|
b.Property<string>("Value");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("ApplicationConfiguration");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<string>("Content");
|
||||||
|
|
||||||
|
b.Property<string>("SettingsName");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("GlobalSettings");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
47
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.cs
Normal file
47
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.cs
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Migrations.Settings
|
||||||
|
{
|
||||||
|
public partial class Inital : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ApplicationConfiguration",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Type = table.Column<int>(nullable: false),
|
||||||
|
Value = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ApplicationConfiguration", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "GlobalSettings",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Content = table.Column<string>(nullable: true),
|
||||||
|
SettingsName = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_GlobalSettings", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ApplicationConfiguration");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "GlobalSettings");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
// <auto-generated />
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Ombi.Store.Context;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Migrations.Settings
|
||||||
|
{
|
||||||
|
[DbContext(typeof(SettingsContext))]
|
||||||
|
partial class SettingsContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065");
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("Type");
|
||||||
|
|
||||||
|
b.Property<string>("Value");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("ApplicationConfiguration");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<string>("Content");
|
||||||
|
|
||||||
|
b.Property<string>("SettingsName");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("GlobalSettings");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,16 +8,20 @@ namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public class ApplicationConfigRepository : IApplicationConfigRepository
|
public class ApplicationConfigRepository : IApplicationConfigRepository
|
||||||
{
|
{
|
||||||
public ApplicationConfigRepository(IOmbiContext ctx)
|
public ApplicationConfigRepository(ISettingsContext ctx)
|
||||||
{
|
{
|
||||||
Ctx = ctx;
|
Ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IOmbiContext Ctx { get; }
|
private ISettingsContext Ctx { get; }
|
||||||
|
|
||||||
public async Task<ApplicationConfiguration> Get(ConfigurationTypes type)
|
public Task<ApplicationConfiguration> GetAsync(ConfigurationTypes type)
|
||||||
{
|
{
|
||||||
return await Ctx.ApplicationConfigurations.FirstOrDefaultAsync(x => x.Type == type);
|
return Ctx.ApplicationConfigurations.FirstOrDefaultAsync(x => x.Type == type);
|
||||||
|
}
|
||||||
|
public ApplicationConfiguration Get(ConfigurationTypes type)
|
||||||
|
{
|
||||||
|
return Ctx.ApplicationConfigurations.FirstOrDefault(x => x.Type == type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
105
src/Ombi.Store/Repository/BaseRepository.cs
Normal file
105
src/Ombi.Store/Repository/BaseRepository.cs
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Query;
|
||||||
|
using Ombi.Store.Context;
|
||||||
|
using Ombi.Store.Entities;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Repository
|
||||||
|
{
|
||||||
|
public class BaseRepository<T, U> : IRepository<T> where T : Entity where U : IDbContext
|
||||||
|
{
|
||||||
|
public BaseRepository(U ctx)
|
||||||
|
{
|
||||||
|
_ctx = ctx;
|
||||||
|
_db = _ctx.Set<T>();
|
||||||
|
}
|
||||||
|
public DbSet<T> _db { get; }
|
||||||
|
private readonly U _ctx;
|
||||||
|
|
||||||
|
public async Task<T> Find(object key)
|
||||||
|
{
|
||||||
|
return await _db.FindAsync(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<T> GetAll()
|
||||||
|
{
|
||||||
|
return _db.AsQueryable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<T> FirstOrDefaultAsync(Expression<Func<T,bool>> predicate)
|
||||||
|
{
|
||||||
|
return await _db.FirstOrDefaultAsync(predicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddRange(IEnumerable<T> content, bool save = true)
|
||||||
|
{
|
||||||
|
_db.AddRange(content);
|
||||||
|
if (save)
|
||||||
|
{
|
||||||
|
await _ctx.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<T> Add(T content)
|
||||||
|
{
|
||||||
|
await _db.AddAsync(content);
|
||||||
|
await _ctx.SaveChangesAsync();
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Delete(T request)
|
||||||
|
{
|
||||||
|
_db.Remove(request);
|
||||||
|
await _ctx.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteRange(IEnumerable<T> req)
|
||||||
|
{
|
||||||
|
_db.RemoveRange(req);
|
||||||
|
await _ctx.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> SaveChangesAsync()
|
||||||
|
{
|
||||||
|
return await _ctx.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIncludableQueryable<TEntity, TProperty> Include<TEntity, TProperty>(
|
||||||
|
IQueryable<TEntity> source, Expression<Func<TEntity, TProperty>> navigationPropertyPath)
|
||||||
|
where TEntity : class
|
||||||
|
{
|
||||||
|
return source.Include(navigationPropertyPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ExecuteSql(string sql)
|
||||||
|
{
|
||||||
|
await _ctx.Database.ExecuteSqlCommandAsync(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool _disposed;
|
||||||
|
// Protected implementation of Dispose pattern.
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (_disposed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
_ctx?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
_disposed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,15 +35,15 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public class EmbyContentRepository : Repository<EmbyContent>, IEmbyContentRepository
|
public class EmbyContentRepository : ExternalRepository<EmbyContent>, IEmbyContentRepository
|
||||||
{
|
{
|
||||||
|
|
||||||
public EmbyContentRepository(IOmbiContext db):base(db)
|
public EmbyContentRepository(IExternalContext db):base(db)
|
||||||
{
|
{
|
||||||
Db = db;
|
Db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IOmbiContext Db { get; }
|
private IExternalContext Db { get; }
|
||||||
|
|
||||||
|
|
||||||
public async Task<EmbyContent> GetByImdbId(string imdbid)
|
public async Task<EmbyContent> GetByImdbId(string imdbid)
|
||||||
|
|
12
src/Ombi.Store/Repository/ExternalRepository.cs
Normal file
12
src/Ombi.Store/Repository/ExternalRepository.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using Ombi.Store.Context;
|
||||||
|
using Ombi.Store.Entities;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Repository
|
||||||
|
{
|
||||||
|
public class ExternalRepository<T> : BaseRepository<T, IExternalContext>, IExternalRepository<T> where T : Entity
|
||||||
|
{
|
||||||
|
public ExternalRepository(IExternalContext ctx) : base(ctx)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public interface IApplicationConfigRepository
|
public interface IApplicationConfigRepository
|
||||||
{
|
{
|
||||||
Task<ApplicationConfiguration> Get(ConfigurationTypes type);
|
Task<ApplicationConfiguration> GetAsync(ConfigurationTypes type);
|
||||||
|
ApplicationConfiguration Get(ConfigurationTypes type);
|
||||||
}
|
}
|
||||||
}
|
}
|
30
src/Ombi.Store/Repository/IExternalRepository.cs
Normal file
30
src/Ombi.Store/Repository/IExternalRepository.cs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Query;
|
||||||
|
using Ombi.Store.Entities;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Repository
|
||||||
|
{
|
||||||
|
public interface IExternalRepository<T> : IDisposable where T : Entity
|
||||||
|
{
|
||||||
|
Task<T> Find(object key);
|
||||||
|
IQueryable<T> GetAll();
|
||||||
|
Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate);
|
||||||
|
Task AddRange(IEnumerable<T> content, bool save = true);
|
||||||
|
Task<T> Add(T content);
|
||||||
|
Task DeleteRange(IEnumerable<T> req);
|
||||||
|
Task Delete(T request);
|
||||||
|
Task<int> SaveChangesAsync();
|
||||||
|
|
||||||
|
IIncludableQueryable<TEntity, TProperty> Include<TEntity, TProperty>(
|
||||||
|
IQueryable<TEntity> source, Expression<Func<TEntity, TProperty>> navigationPropertyPath)
|
||||||
|
where TEntity : class;
|
||||||
|
|
||||||
|
Task ExecuteSql(string sql);
|
||||||
|
DbSet<T> _db { get; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public interface IPlexContentRepository : IRepository<PlexServerContent>
|
public interface IPlexContentRepository : IExternalRepository<PlexServerContent>
|
||||||
{
|
{
|
||||||
Task<bool> ContentExists(string providerId);
|
Task<bool> ContentExists(string providerId);
|
||||||
Task<PlexServerContent> Get(string providerId);
|
Task<PlexServerContent> Get(string providerId);
|
||||||
|
|
|
@ -36,15 +36,15 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public class PlexServerContentRepository : Repository<PlexServerContent>, IPlexContentRepository
|
public class PlexServerContentRepository : ExternalRepository<PlexServerContent>, IPlexContentRepository
|
||||||
{
|
{
|
||||||
|
|
||||||
public PlexServerContentRepository(IOmbiContext db) : base(db)
|
public PlexServerContentRepository(IExternalContext db) : base(db)
|
||||||
{
|
{
|
||||||
Db = db;
|
Db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IOmbiContext Db { get; }
|
private IExternalContext Db { get; }
|
||||||
|
|
||||||
|
|
||||||
public async Task<bool> ContentExists(string providerId)
|
public async Task<bool> ContentExists(string providerId)
|
||||||
|
|
|
@ -1,105 +1,12 @@
|
||||||
using System;
|
using Ombi.Store.Context;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Query;
|
|
||||||
using Ombi.Store.Context;
|
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public class Repository<T> : IRepository<T> where T : Entity
|
public class Repository<T> : BaseRepository<T,IOmbiContext>, IRepository<T> where T : Entity
|
||||||
{
|
{
|
||||||
public Repository(IOmbiContext ctx)
|
public Repository(IOmbiContext ctx) : base(ctx)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
|
||||||
_db = _ctx.Set<T>();
|
|
||||||
}
|
|
||||||
public DbSet<T> _db { get; }
|
|
||||||
private readonly IOmbiContext _ctx;
|
|
||||||
|
|
||||||
public async Task<T> Find(object key)
|
|
||||||
{
|
|
||||||
return await _db.FindAsync(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQueryable<T> GetAll()
|
|
||||||
{
|
|
||||||
return _db.AsQueryable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<T> FirstOrDefaultAsync(Expression<Func<T,bool>> predicate)
|
|
||||||
{
|
|
||||||
return await _db.FirstOrDefaultAsync(predicate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task AddRange(IEnumerable<T> content, bool save = true)
|
|
||||||
{
|
|
||||||
_db.AddRange(content);
|
|
||||||
if (save)
|
|
||||||
{
|
|
||||||
await _ctx.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<T> Add(T content)
|
|
||||||
{
|
|
||||||
await _db.AddAsync(content);
|
|
||||||
await _ctx.SaveChangesAsync();
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Delete(T request)
|
|
||||||
{
|
|
||||||
_db.Remove(request);
|
|
||||||
await _ctx.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task DeleteRange(IEnumerable<T> req)
|
|
||||||
{
|
|
||||||
_db.RemoveRange(req);
|
|
||||||
await _ctx.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<int> SaveChangesAsync()
|
|
||||||
{
|
|
||||||
return await _ctx.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IIncludableQueryable<TEntity, TProperty> Include<TEntity, TProperty>(
|
|
||||||
IQueryable<TEntity> source, Expression<Func<TEntity, TProperty>> navigationPropertyPath)
|
|
||||||
where TEntity : class
|
|
||||||
{
|
|
||||||
return source.Include(navigationPropertyPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ExecuteSql(string sql)
|
|
||||||
{
|
|
||||||
await _ctx.Database.ExecuteSqlCommandAsync(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private bool _disposed;
|
|
||||||
// Protected implementation of Dispose pattern.
|
|
||||||
protected virtual void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (_disposed)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
_ctx?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
_disposed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,13 +12,13 @@ namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public class SettingsJsonRepository : ISettingsRepository
|
public class SettingsJsonRepository : ISettingsRepository
|
||||||
{
|
{
|
||||||
public SettingsJsonRepository(IOmbiContext ctx, ICacheService mem)
|
public SettingsJsonRepository(ISettingsContext ctx, ICacheService mem)
|
||||||
{
|
{
|
||||||
Db = ctx;
|
Db = ctx;
|
||||||
_cache = mem;
|
_cache = mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IOmbiContext Db { get; }
|
private ISettingsContext Db { get; }
|
||||||
private readonly ICacheService _cache;
|
private readonly ICacheService _cache;
|
||||||
|
|
||||||
public GlobalSettings Insert(GlobalSettings entity)
|
public GlobalSettings Insert(GlobalSettings entity)
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Ombi.Controllers
|
||||||
{
|
{
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||||
|
|
||||||
var images = await FanartTvApi.GetTvImages(tvdbid, key.Value);
|
var images = await FanartTvApi.GetTvImages(tvdbid, key.Value);
|
||||||
if (images == null)
|
if (images == null)
|
||||||
|
@ -64,7 +64,7 @@ namespace Ombi.Controllers
|
||||||
[HttpGet("poster/movie/{movieDbId}")]
|
[HttpGet("poster/movie/{movieDbId}")]
|
||||||
public async Task<string> GetMoviePoster(string movieDbId)
|
public async Task<string> GetMoviePoster(string movieDbId)
|
||||||
{
|
{
|
||||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||||
|
|
||||||
var images = await FanartTvApi.GetMovieImages(movieDbId, key.Value);
|
var images = await FanartTvApi.GetMovieImages(movieDbId, key.Value);
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ namespace Ombi.Controllers
|
||||||
{
|
{
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||||
|
|
||||||
var images = await FanartTvApi.GetTvImages(tvdbid, key.Value);
|
var images = await FanartTvApi.GetTvImages(tvdbid, key.Value);
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ namespace Ombi.Controllers
|
||||||
[HttpGet("background/movie/{movieDbId}")]
|
[HttpGet("background/movie/{movieDbId}")]
|
||||||
public async Task<string> GetMovieBackground(string movieDbId)
|
public async Task<string> GetMovieBackground(string movieDbId)
|
||||||
{
|
{
|
||||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||||
|
|
||||||
var images = await FanartTvApi.GetMovieImages(movieDbId, key.Value);
|
var images = await FanartTvApi.GetMovieImages(movieDbId, key.Value);
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ namespace Ombi.Controllers
|
||||||
{
|
{
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||||
|
|
||||||
var images = await FanartTvApi.GetTvImages(tvdbid, key.Value);
|
var images = await FanartTvApi.GetTvImages(tvdbid, key.Value);
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ namespace Ombi.Controllers
|
||||||
var movieUrl = string.Empty;
|
var movieUrl = string.Empty;
|
||||||
var tvUrl = string.Empty;
|
var tvUrl = string.Empty;
|
||||||
|
|
||||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||||
|
|
||||||
if (moviesArray.Length > 0)
|
if (moviesArray.Length > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,7 +45,9 @@ namespace Ombi
|
||||||
var urlValue = string.Empty;
|
var urlValue = string.Empty;
|
||||||
var instance = StoragePathSingleton.Instance;
|
var instance = StoragePathSingleton.Instance;
|
||||||
instance.StoragePath = storagePath ?? string.Empty;
|
instance.StoragePath = storagePath ?? string.Empty;
|
||||||
using (var ctx = new OmbiContext())
|
// Check if we need to migrate the settings
|
||||||
|
CheckAndMigrate();
|
||||||
|
using (var ctx = new SettingsContext())
|
||||||
{
|
{
|
||||||
var config = ctx.ApplicationConfigurations.ToList();
|
var config = ctx.ApplicationConfigurations.ToList();
|
||||||
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
|
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
|
||||||
|
@ -82,7 +84,7 @@ namespace Ombi
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(baseUrl.HasValue() && !baseUrl.Equals(dbBaseUrl.Value))
|
else if (baseUrl.HasValue() && !baseUrl.Equals(dbBaseUrl.Value))
|
||||||
{
|
{
|
||||||
dbBaseUrl.Value = baseUrl;
|
dbBaseUrl.Value = baseUrl;
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
|
@ -96,6 +98,139 @@ namespace Ombi
|
||||||
BuildWebHost(args).Run();
|
BuildWebHost(args).Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is to remove the Settings from the Ombi.db to the "new"
|
||||||
|
/// OmbiSettings.db
|
||||||
|
///
|
||||||
|
/// Ombi is hitting a limitation with SQLite where there is a lot of database activity
|
||||||
|
/// and SQLite does not handle concurrency at all, causing db locks.
|
||||||
|
///
|
||||||
|
/// Splitting it all out into it's own DB helps with this.
|
||||||
|
/// </summary>
|
||||||
|
private static void CheckAndMigrate()
|
||||||
|
{
|
||||||
|
var doneGlobal = false;
|
||||||
|
var doneConfig = false;
|
||||||
|
using (var ombi = new OmbiContext())
|
||||||
|
using (var settings = new SettingsContext())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ombi.Settings.Any())
|
||||||
|
{
|
||||||
|
// OK migrate it!
|
||||||
|
var allSettings = ombi.Settings.ToList();
|
||||||
|
settings.Settings.AddRange(allSettings);
|
||||||
|
doneGlobal = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for any application settings
|
||||||
|
|
||||||
|
if (ombi.ApplicationConfigurations.Any())
|
||||||
|
{
|
||||||
|
// OK migrate it!
|
||||||
|
var allSettings = ombi.ApplicationConfigurations.ToList();
|
||||||
|
settings.ApplicationConfigurations.AddRange(allSettings);
|
||||||
|
doneConfig = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.SaveChanges();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now delete the old stuff
|
||||||
|
if (doneGlobal)
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM GlobalSettings");
|
||||||
|
if (doneConfig)
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM ApplicationConfiguration");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now migrate all the external stuff
|
||||||
|
using (var ombi = new OmbiContext())
|
||||||
|
using (var external = new ExternalContext())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
if (ombi.PlexEpisode.Any())
|
||||||
|
{
|
||||||
|
external.PlexEpisode.AddRange(ombi.PlexEpisode.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM PlexEpisode");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ombi.PlexSeasonsContent.Any())
|
||||||
|
{
|
||||||
|
external.PlexSeasonsContent.AddRange(ombi.PlexSeasonsContent.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM PlexSeasonsContent");
|
||||||
|
}
|
||||||
|
if (ombi.PlexServerContent.Any())
|
||||||
|
{
|
||||||
|
external.PlexServerContent.AddRange(ombi.PlexServerContent.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM PlexServerContent");
|
||||||
|
}
|
||||||
|
if (ombi.EmbyEpisode.Any())
|
||||||
|
{
|
||||||
|
external.EmbyEpisode.AddRange(ombi.EmbyEpisode.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM EmbyEpisode");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ombi.EmbyContent.Any())
|
||||||
|
{
|
||||||
|
external.EmbyContent.AddRange(ombi.EmbyContent.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM EmbyContent");
|
||||||
|
}
|
||||||
|
if (ombi.RadarrCache.Any())
|
||||||
|
{
|
||||||
|
external.RadarrCache.AddRange(ombi.RadarrCache.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM RadarrCache");
|
||||||
|
}
|
||||||
|
if (ombi.SonarrCache.Any())
|
||||||
|
{
|
||||||
|
external.SonarrCache.AddRange(ombi.SonarrCache.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM SonarrCache");
|
||||||
|
}
|
||||||
|
if (ombi.LidarrAlbumCache.Any())
|
||||||
|
{
|
||||||
|
external.LidarrAlbumCache.AddRange(ombi.LidarrAlbumCache.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM LidarrAlbumCache");
|
||||||
|
}
|
||||||
|
if (ombi.LidarrArtistCache.Any())
|
||||||
|
{
|
||||||
|
external.LidarrArtistCache.AddRange(ombi.LidarrArtistCache.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM LidarrArtistCache");
|
||||||
|
}
|
||||||
|
if (ombi.SickRageEpisodeCache.Any())
|
||||||
|
{
|
||||||
|
external.SickRageEpisodeCache.AddRange(ombi.SickRageEpisodeCache.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM SickRageEpisodeCache");
|
||||||
|
}
|
||||||
|
if (ombi.SickRageCache.Any())
|
||||||
|
{
|
||||||
|
external.SickRageCache.AddRange(ombi.SickRageCache.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM SickRageCache");
|
||||||
|
}
|
||||||
|
if (ombi.CouchPotatoCache.Any())
|
||||||
|
{
|
||||||
|
external.CouchPotatoCache.AddRange(ombi.CouchPotatoCache.ToList());
|
||||||
|
ombi.Database.ExecuteSqlCommand("DELETE FROM CouchPotatoCache");
|
||||||
|
}
|
||||||
|
|
||||||
|
external.SaveChanges();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static void DeleteSchedulesDb()
|
private static void DeleteSchedulesDb()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -177,7 +177,7 @@ namespace Ombi
|
||||||
|
|
||||||
// Check if it's in the startup args
|
// Check if it's in the startup args
|
||||||
var appConfig = serviceProvider.GetService<IApplicationConfigRepository>();
|
var appConfig = serviceProvider.GetService<IApplicationConfigRepository>();
|
||||||
var baseUrl = appConfig.Get(ConfigurationTypes.BaseUrl).Result;
|
var baseUrl = appConfig.Get(ConfigurationTypes.BaseUrl);
|
||||||
if (baseUrl != null)
|
if (baseUrl != null)
|
||||||
{
|
{
|
||||||
if (baseUrl.Value.HasValue())
|
if (baseUrl.Value.HasValue())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue