Develop into v4

pull/3895/head
tidusjar 5 years ago
commit 2365341207

1
.gitignore vendored

@ -246,3 +246,4 @@ _Pvt_Extensions
# Ignore local vscode config
*.vscode
/src/Ombi/database.json

@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore;
using Ombi.Core.Authentication;
using Ombi.Core.Rule.Interfaces;
using Ombi.Helpers;
using Ombi.Store.Entities;
using Ombi.Store.Entities.Requests;
namespace Ombi.Core.Rule.Rules.Request

@ -7,12 +7,12 @@ namespace Ombi.Core.Rule.Rules.Request
{
public class SonarrCacheRequestRule : BaseRequestRule, IRules<BaseRequest>
{
public SonarrCacheRequestRule(IExternalContext ctx)
public SonarrCacheRequestRule(ExternalContext ctx)
{
_ctx = ctx;
}
private readonly IExternalContext _ctx;
private readonly ExternalContext _ctx;
public Task<RuleResult> Execute(BaseRequest obj)
{

@ -34,12 +34,12 @@ namespace Ombi.Core.Rule.Rules.Search
{
public class SonarrCacheSearchRule : BaseSearchRule, IRules<SearchViewModel>
{
public SonarrCacheSearchRule(IExternalContext ctx)
public SonarrCacheSearchRule(ExternalContext ctx)
{
_ctx = ctx;
}
private readonly IExternalContext _ctx;
private readonly ExternalContext _ctx;
public Task<RuleResult> Execute(SearchViewModel obj)
{

@ -10,12 +10,12 @@ namespace Ombi.Core.Rule.Rules
{
public class SonarrCacheRule
{
public SonarrCacheRule(IExternalContext ctx)
public SonarrCacheRule(ExternalContext ctx)
{
_ctx = ctx;
}
private readonly IExternalContext _ctx;
private readonly ExternalContext _ctx;
public async Task<RuleResult> Execute(BaseRequest obj)
{

@ -151,13 +151,13 @@ namespace Ombi.DependencyInjection
}
public static void RegisterStore(this IServiceCollection services) {
services.AddDbContext<OmbiContext>();
services.AddDbContext<SettingsContext>();
services.AddDbContext<ExternalContext>();
//services.AddDbContext<OmbiContext>();
//services.AddDbContext<SettingsContext>();
//services.AddDbContext<ExternalContext>();
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.AddScoped<OmbiContext, 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<ExternalContext, ExternalContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6
services.AddScoped<ISettingsRepository, SettingsJsonRepository>();
services.AddScoped<ISettingsResolver, SettingsResolver>();
services.AddScoped<IPlexContentRepository, PlexServerContentRepository>();

@ -23,6 +23,7 @@ namespace Ombi.Schedule.Tests
scheduleMock.Verify(x => x.TriggerJob(It.Is<JobKey>(j => j.Name == "ABC"),
default(CancellationToken)), Times.Once);
}
}
public class QuartzMock : OmbiQuartz

@ -45,7 +45,7 @@ namespace Ombi.Schedule.Jobs.Couchpotato
public class CouchPotatoSync : ICouchPotatoSync
{
public CouchPotatoSync(ISettingsService<CouchPotatoSettings> cpSettings,
ICouchPotatoApi api, ILogger<CouchPotatoSync> log, IExternalContext ctx, IHubContext<NotificationHub> hub)
ICouchPotatoApi api, ILogger<CouchPotatoSync> log, ExternalContext ctx, IHubContext<NotificationHub> hub)
{
_settings = cpSettings;
_api = api;
@ -58,7 +58,7 @@ namespace Ombi.Schedule.Jobs.Couchpotato
private readonly ISettingsService<CouchPotatoSettings> _settings;
private readonly ICouchPotatoApi _api;
private readonly ILogger<CouchPotatoSync> _log;
private readonly IExternalContext _ctx;
private readonly ExternalContext _ctx;
private readonly IHubContext<NotificationHub> _notification;
public async Task Execute(IJobExecutionContext job)

@ -20,7 +20,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
{
public class LidarrAlbumSync : ILidarrAlbumSync
{
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, IExternalContext ctx,
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, ExternalContext ctx,
IBackgroundJobClient job, ILidarrAvailabilityChecker availability, IHubContext<NotificationHub> notification)
{
_lidarrSettings = lidarr;
@ -35,7 +35,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
private readonly ILidarrApi _lidarrApi;
private readonly ILogger _logger;
private readonly IExternalContext _ctx;
private readonly ExternalContext _ctx;
private readonly IBackgroundJobClient _job;
private readonly ILidarrAvailabilityChecker _availability;
private readonly IHubContext<NotificationHub> _notification;

@ -20,7 +20,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
{
public class LidarrArtistSync : ILidarrArtistSync
{
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, IExternalContext ctx
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, ExternalContext ctx
, IHubContext<NotificationHub> notification)
{
_lidarrSettings = lidarr;
@ -33,7 +33,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
private readonly ILidarrApi _lidarrApi;
private readonly ILogger _logger;
private readonly IExternalContext _ctx;
private readonly ExternalContext _ctx;
private readonly IHubContext<NotificationHub> _notification;
public async Task Execute(IJobExecutionContext job)

@ -209,7 +209,7 @@ namespace Ombi.Schedule.Jobs.Ombi
continue;
}
// BCC the messages
message.Bcc.Add(new MailboxAddress(user.Email, user.Email));
message.Bcc.Add(new MailboxAddress(user.Email.Trim(), user.Email.Trim()));
}
// Send the email

@ -17,7 +17,7 @@ namespace Ombi.Schedule.Jobs.Radarr
{
public class RadarrSync : IRadarrSync
{
public RadarrSync(ISettingsService<RadarrSettings> radarr, IRadarrApi radarrApi, ILogger<RadarrSync> log, IExternalContext ctx)
public RadarrSync(ISettingsService<RadarrSettings> radarr, IRadarrApi radarrApi, ILogger<RadarrSync> log, ExternalContext ctx)
{
RadarrSettings = radarr;
RadarrApi = radarrApi;
@ -29,7 +29,7 @@ namespace Ombi.Schedule.Jobs.Radarr
private ISettingsService<RadarrSettings> RadarrSettings { get; }
private IRadarrApi RadarrApi { get; }
private ILogger<RadarrSync> Logger { get; }
private readonly IExternalContext _ctx;
private readonly ExternalContext _ctx;
private static readonly SemaphoreSlim SemaphoreSlim = new SemaphoreSlim(1, 1);

@ -17,7 +17,7 @@ namespace Ombi.Schedule.Jobs.SickRage
{
public class SickRageSync : ISickRageSync
{
public SickRageSync(ISettingsService<SickRageSettings> s, ISickRageApi api, ILogger<SickRageSync> l, IExternalContext ctx)
public SickRageSync(ISettingsService<SickRageSettings> s, ISickRageApi api, ILogger<SickRageSync> l, ExternalContext ctx)
{
_settings = s;
_api = api;
@ -29,7 +29,7 @@ namespace Ombi.Schedule.Jobs.SickRage
private readonly ISettingsService<SickRageSettings> _settings;
private readonly ISickRageApi _api;
private readonly ILogger<SickRageSync> _log;
private readonly IExternalContext _ctx;
private readonly ExternalContext _ctx;
public async Task Execute(IJobExecutionContext job)
{

@ -20,7 +20,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
{
public class SonarrSync : ISonarrSync
{
public SonarrSync(ISettingsService<SonarrSettings> s, ISonarrApi api, ILogger<SonarrSync> l, IExternalContext ctx)
public SonarrSync(ISettingsService<SonarrSettings> s, ISonarrApi api, ILogger<SonarrSync> l, ExternalContext ctx)
{
_settings = s;
_api = api;
@ -32,7 +32,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
private readonly ISettingsService<SonarrSettings> _settings;
private readonly ISonarrApi _api;
private readonly ILogger<SonarrSync> _log;
private readonly IExternalContext _ctx;
private readonly ExternalContext _ctx;
public async Task Execute(IJobExecutionContext job)
{

@ -5,16 +5,22 @@ using Ombi.Store.Entities;
namespace Ombi.Store.Context
{
public sealed class ExternalContext : DbContext, IExternalContext
public abstract class ExternalContext : DbContext
{
private static bool _created;
public ExternalContext()
protected ExternalContext(DbContextOptions<ExternalContext> options) : base(options)
{
if (_created) return;
_created = true;
Database.SetCommandTimeout(60);
Database.Migrate();
}
/// <summary>
/// This allows a sub class to call the base class 'DbContext' non typed constructor
/// This is need because instances of the subclasses will use a specific typed DbContextOptions
/// which can not be converted into the parameter in the above constructor
/// </summary>
/// <param name="options"></param>
protected ExternalContext(DbContextOptions options)
: base(options)
{
}
public DbSet<PlexServerContent> PlexServerContent { get; set; }
@ -32,16 +38,6 @@ namespace Ombi.Store.Context
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)
@ -57,18 +53,5 @@ namespace Ombi.Store.Context
base.OnModelCreating(builder);
}
public void Seed()
{
// VACUUM;
Database.ExecuteSqlCommand("VACUUM;");
using (var tran = Database.BeginTransaction())
{
SaveChanges();
tran.Commit();
}
}
}
}

@ -1,21 +0,0 @@
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; }
}
}

@ -1,44 +0,0 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Ombi.Store.Entities;
using Ombi.Store.Entities.Requests;
namespace Ombi.Store.Context
{
public interface IOmbiContext : IDbContext
{
//DbSet<PlexServerContent> PlexServerContent { get; set; }
//DbSet<PlexEpisode> PlexEpisode { get; set; }
DbSet<GlobalSettings> Settings { get; set; }
//DbSet<RadarrCache> RadarrCache { get; set; }
//DbSet<EmbyContent> EmbyContent { get; set; }
//DbSet<EmbyEpisode> EmbyEpisode { get; set; }
DbSet<NotificationTemplates> NotificationTemplates { get; set; }
DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
DbSet<Votes> Votes { get; set; }
void Seed();
DbSet<Audit> Audit { get; set; }
DbSet<MovieRequests> MovieRequests { get; set; }
DbSet<AlbumRequest> AlbumRequests { get; set; }
DbSet<TvRequests> TvRequests { get; set; }
DbSet<ChildRequests> ChildRequests { get; set; }
DbSet<Issues> Issues { get; set; }
DbSet<IssueCategory> IssueCategories { get; set; }
DbSet<Tokens> Tokens { get; set; }
DbSet<SonarrCache> SonarrCache { get; set; }
//DbSet<SonarrEpisodeCache> SonarrEpisodeCache { get; set; }
//DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
//DbSet<SickRageCache> SickRageCache { get; set; }
//DbSet<LidarrArtistCache> LidarrArtistCache { get; set; }
//DbSet<LidarrAlbumCache> LidarrAlbumCache { get; set; }
//DbSet<SickRageEpisodeCache> SickRageEpisodeCache { get; set; }
DbSet<RequestLog> RequestLogs { get; set; }
DbSet<RecentlyAddedLog> RecentlyAddedLogs { get; set; }
DbSet<RequestSubscription> RequestSubscription { get; set; }
}
}

@ -1,11 +0,0 @@
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; }
}
}

@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.MySql
{
public sealed class ExternalMySqlContext : ExternalContext
{
private static bool _created;
public ExternalMySqlContext(DbContextOptions<ExternalMySqlContext> options) : base(options)
{
if (_created) return;
_created = true;
Database.Migrate();
}
}
}

@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.MySql
{
public sealed class OmbiMySqlContext : OmbiContext
{
private static bool _created;
public OmbiMySqlContext(DbContextOptions<OmbiMySqlContext> options) : base(options)
{
if (_created) return;
_created = true;
Database.Migrate();
}
}
}

@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.MySql
{
public sealed class SettingsMySqlContext : SettingsContext
{
private static bool _created;
public SettingsMySqlContext(DbContextOptions<SettingsMySqlContext> options) : base(options)
{
if (_created) return;
_created = true;
Database.Migrate();
}
}
}

@ -10,29 +10,26 @@ using Ombi.Store.Entities.Requests;
namespace Ombi.Store.Context
{
public sealed class OmbiContext : IdentityDbContext<OmbiUser>, IOmbiContext
public abstract class OmbiContext : IdentityDbContext<OmbiUser>
{
private static bool _created;
public OmbiContext()
protected OmbiContext(DbContextOptions<OmbiContext> options) : base(options)
{
if (_created) return;
}
_created = true;
Database.SetCommandTimeout(60);
Database.Migrate();
/// <summary>
/// This allows a sub class to call the base class 'DbContext' non typed constructor
/// This is need because instances of the subclasses will use a specific typed DbContextOptions
/// which can not be converted into the parameter in the above constructor
/// </summary>
/// <param name="options"></param>
protected OmbiContext(DbContextOptions options)
: base(options)
{
}
public DbSet<NotificationTemplates> NotificationTemplates { get; set; }
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
public DbSet<PlexServerContent> PlexServerContent { get; set; }
public DbSet<PlexSeasonsContent> PlexSeasonsContent { get; set; }
public DbSet<PlexEpisode> PlexEpisode { get; set; }
public DbSet<GlobalSettings> Settings { 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<MovieRequests> MovieRequests { get; set; }
public DbSet<AlbumRequest> AlbumRequests { get; set; }
@ -49,44 +46,11 @@ namespace Ombi.Store.Context
public DbSet<Audit> Audit { get; set; }
public DbSet<Tokens> Tokens { 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; }
public DbSet<RequestSubscription> RequestSubscription { get; set; }
public DbSet<UserNotificationPreferences> UserNotificationPreferences { get; set; }
public DbSet<UserQualityProfiles> UserQualityProfileses { get; set; }
public DbSet<RequestQueue> RequestQueue { 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, "Ombi.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()
{

@ -1,39 +1,34 @@
using System.IO;
using System.Linq;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Ombi.Helpers;
using Ombi.Store.Entities;
namespace Ombi.Store.Context
{
public sealed class SettingsContext : DbContext, ISettingsContext
public abstract class SettingsContext : DbContext
{
private static bool _created;
public SettingsContext()
protected SettingsContext(DbContextOptions<SettingsContext> options) : base(options)
{
if (_created) return;
_created = true;
Database.SetCommandTimeout(60);
Database.Migrate();
}
public DbSet<GlobalSettings> Settings { get; set; }
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
/// <summary>
/// This allows a sub class to call the base class 'DbContext' non typed constructor
/// This is need because instances of the subclasses will use a specific typed DbContextOptions
/// which can not be converted into the parameter in the above constructor
/// </summary>
/// <param name="options"></param>
protected SettingsContext(DbContextOptions options)
: base(options)
{
var i = StoragePathSingleton.Instance;
if (string.IsNullOrEmpty(i.StoragePath))
{
i.StoragePath = string.Empty;
}
optionsBuilder.UseSqlite($"Data Source={Path.Combine(i.StoragePath, "OmbiSettings" + ".db")}");
}
public DbSet<GlobalSettings> Settings { get; set; }
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
public void Seed()
{
using (var tran = Database.BeginTransaction())
{
// Add the tokens

@ -0,0 +1,33 @@
using System;
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.Sqlite
{
public sealed class ExternalSqliteContext : ExternalContext
{
private static bool _created;
public ExternalSqliteContext(DbContextOptions<ExternalSqliteContext> options) : base(options)
{
if (_created) return;
_created = true;
Upgrade();
Database.SetCommandTimeout(60);
Database.Migrate();
}
private void Upgrade()
{
try
{
Database.ExecuteSqlCommand(@"INSERT INTO __EFMigrationsHistory (MigrationId,ProductVersion)
VALUES('20191103205133_Inital', '2.2.6-servicing-10079'); ");
}
catch (Exception)
{
// ignored
}
}
}
}

@ -0,0 +1,34 @@
using System;
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.Sqlite
{
public sealed class OmbiSqliteContext : OmbiContext
{
private static bool _created;
public OmbiSqliteContext(DbContextOptions<OmbiSqliteContext> options) : base(options)
{
if (_created) return;
_created = true;
Upgrade();
Database.SetCommandTimeout(60);
Database.Migrate();
}
private void Upgrade()
{
try
{
Database.ExecuteSqlCommand(@"INSERT INTO __EFMigrationsHistory (MigrationId,ProductVersion)
VALUES('20191102235658_Inital', '2.2.6-servicing-10079'); ");
}
catch (Exception)
{
// ignored
}
}
}
}

@ -0,0 +1,32 @@
using System;
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.Sqlite
{
public sealed class SettingsSqliteContext : SettingsContext
{
private static bool _created;
public SettingsSqliteContext(DbContextOptions<SettingsSqliteContext> options) : base(options)
{
if (_created) return;
_created = true;
Upgrade();
Database.SetCommandTimeout(60);
Database.Migrate();
}
private void Upgrade()
{
try
{
Database.ExecuteSqlCommand(@"INSERT INTO __EFMigrationsHistory (MigrationId,ProductVersion)
VALUES('20191103205204_Inital', '2.2.6-servicing-10079'); ");
}
catch (Exception)
{
// ignored
}
}
}
}

@ -1 +1,3 @@
dotnet ef migrations add Inital --context OmbiContext --startup-project ../Ombi/Ombi.csproj
dotnet ef migrations add Inital --context OmbiContext --startup-project ../Ombi/Ombi.csproj
If running migrations for any db provider other than Sqlite, then ensure the database.json is pointing at the correct DB type

@ -0,0 +1,315 @@
// <auto-generated />
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("20191103213915_Inital")]
partial class Inital
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
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<int?>("RequestId");
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
}
}
}

@ -0,0 +1,310 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.ExternalMySql
{
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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),
RequestId = table.Column<int>(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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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");
}
}
}

@ -0,0 +1,313 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context.MySql;
namespace Ombi.Store.Migrations.ExternalMySql
{
[DbContext(typeof(ExternalMySqlContext))]
partial class ExternalMySqlContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
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<int?>("RequestId");
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
}
}
}

@ -0,0 +1,314 @@
// <auto-generated />
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("20191103205133_Inital")]
partial class Inital
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
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<int?>("RequestId");
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
}
}
}

@ -0,0 +1,309 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.ExternalSqlite
{
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),
RequestId = table.Column<int>(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");
}
}
}

@ -0,0 +1,312 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context.Sqlite;
namespace Ombi.Store.Migrations.ExternalSqlite
{
[DbContext(typeof(ExternalSqliteContext))]
partial class ExternalSqliteContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
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<int?>("RequestId");
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
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,884 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.OmbiMySql
{
public partial class Inital : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<string>(nullable: false),
Name = table.Column<string>(maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<string>(nullable: false),
UserName = table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
Email = table.Column<string>(maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
TwoFactorEnabled = table.Column<bool>(nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
LockoutEnabled = table.Column<bool>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false),
Alias = table.Column<string>(nullable: true),
UserType = table.Column<int>(nullable: false),
ProviderUserId = table.Column<string>(nullable: true),
LastLoggedIn = table.Column<DateTime>(nullable: true),
EmbyConnectUserId = table.Column<string>(nullable: true),
MovieRequestLimit = table.Column<int>(nullable: true),
EpisodeRequestLimit = table.Column<int>(nullable: true),
MusicRequestLimit = table.Column<int>(nullable: true),
UserAccessToken = table.Column<string>(nullable: true),
PasswordHash = table.Column<string>(nullable: true),
SecurityStamp = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Audit",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DateTime = table.Column<DateTime>(nullable: false),
Description = table.Column<string>(nullable: true),
AuditType = table.Column<int>(nullable: false),
AuditArea = table.Column<int>(nullable: false),
User = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Audit", x => x.Id);
});
migrationBuilder.CreateTable(
name: "IssueCategory",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IssueCategory", x => x.Id);
});
migrationBuilder.CreateTable(
name: "NotificationTemplates",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
NotificationType = table.Column<int>(nullable: false),
Agent = table.Column<int>(nullable: false),
Subject = table.Column<string>(nullable: true),
Message = table.Column<string>(nullable: true),
Enabled = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_NotificationTemplates", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RecentlyAddedLog",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Type = table.Column<int>(nullable: false),
ContentType = table.Column<int>(nullable: false),
ContentId = table.Column<int>(nullable: false),
EpisodeNumber = table.Column<int>(nullable: true),
SeasonNumber = table.Column<int>(nullable: true),
AlbumId = table.Column<string>(nullable: true),
AddedAt = table.Column<DateTime>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RecentlyAddedLog", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RequestQueue",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RequestId = table.Column<int>(nullable: false),
Type = table.Column<int>(nullable: false),
Dts = table.Column<DateTime>(nullable: false),
Error = table.Column<string>(nullable: true),
Completed = table.Column<DateTime>(nullable: true),
RetryCount = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RequestQueue", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TvRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
TvDbId = table.Column<int>(nullable: false),
ImdbId = table.Column<string>(nullable: true),
QualityOverride = table.Column<int>(nullable: true),
RootFolder = table.Column<int>(nullable: true),
Overview = table.Column<string>(nullable: true),
Title = table.Column<string>(nullable: true),
PosterPath = table.Column<string>(nullable: true),
Background = table.Column<string>(nullable: true),
ReleaseDate = table.Column<DateTime>(nullable: false),
Status = table.Column<string>(nullable: true),
TotalSeasons = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TvRequests", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RoleId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AlbumRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(nullable: true),
Approved = table.Column<bool>(nullable: false),
MarkedAsApproved = table.Column<DateTime>(nullable: false),
RequestedDate = table.Column<DateTime>(nullable: false),
Available = table.Column<bool>(nullable: false),
MarkedAsAvailable = table.Column<DateTime>(nullable: true),
RequestedUserId = table.Column<string>(nullable: true),
Denied = table.Column<bool>(nullable: true),
MarkedAsDenied = table.Column<DateTime>(nullable: false),
DeniedReason = table.Column<string>(nullable: true),
RequestType = table.Column<int>(nullable: false),
RequestedByAlias = table.Column<string>(nullable: true),
ForeignAlbumId = table.Column<string>(nullable: true),
ForeignArtistId = table.Column<string>(nullable: true),
Disk = table.Column<string>(nullable: true),
Cover = table.Column<string>(nullable: true),
Rating = table.Column<decimal>(nullable: false),
ReleaseDate = table.Column<DateTime>(nullable: false),
ArtistName = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AlbumRequests", x => x.Id);
table.ForeignKey(
name: "FK_AlbumRequests_AspNetUsers_RequestedUserId",
column: x => x.RequestedUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column<string>(nullable: false),
ProviderKey = table.Column<string>(nullable: false),
ProviderDisplayName = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<string>(nullable: false),
RoleId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column<string>(nullable: false),
LoginProvider = table.Column<string>(nullable: false),
Name = table.Column<string>(nullable: false),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MovieRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(nullable: true),
Approved = table.Column<bool>(nullable: false),
MarkedAsApproved = table.Column<DateTime>(nullable: false),
RequestedDate = table.Column<DateTime>(nullable: false),
Available = table.Column<bool>(nullable: false),
MarkedAsAvailable = table.Column<DateTime>(nullable: true),
RequestedUserId = table.Column<string>(nullable: true),
Denied = table.Column<bool>(nullable: true),
MarkedAsDenied = table.Column<DateTime>(nullable: false),
DeniedReason = table.Column<string>(nullable: true),
RequestType = table.Column<int>(nullable: false),
RequestedByAlias = table.Column<string>(nullable: true),
ImdbId = table.Column<string>(nullable: true),
Overview = table.Column<string>(nullable: true),
PosterPath = table.Column<string>(nullable: true),
ReleaseDate = table.Column<DateTime>(nullable: false),
DigitalReleaseDate = table.Column<DateTime>(nullable: true),
Status = table.Column<string>(nullable: true),
Background = table.Column<string>(nullable: true),
TheMovieDbId = table.Column<int>(nullable: false),
IssueId = table.Column<int>(nullable: true),
RootPathOverride = table.Column<int>(nullable: false),
QualityOverride = table.Column<int>(nullable: false),
LangCode = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MovieRequests", x => x.Id);
table.ForeignKey(
name: "FK_MovieRequests_AspNetUsers_RequestedUserId",
column: x => x.RequestedUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "NotificationUserId",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PlayerId = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: true),
AddedAt = table.Column<DateTime>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_NotificationUserId", x => x.Id);
table.ForeignKey(
name: "FK_NotificationUserId_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "RequestLog",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: true),
RequestType = table.Column<int>(nullable: false),
RequestDate = table.Column<DateTime>(nullable: false),
RequestId = table.Column<int>(nullable: false),
EpisodeCount = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RequestLog", x => x.Id);
table.ForeignKey(
name: "FK_RequestLog_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "RequestSubscription",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: true),
RequestId = table.Column<int>(nullable: false),
RequestType = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RequestSubscription", x => x.Id);
table.ForeignKey(
name: "FK_RequestSubscription_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Tokens",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Token = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Tokens", x => x.Id);
table.ForeignKey(
name: "FK_Tokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "UserNotificationPreferences",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: true),
Agent = table.Column<int>(nullable: false),
Enabled = table.Column<bool>(nullable: false),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UserNotificationPreferences", x => x.Id);
table.ForeignKey(
name: "FK_UserNotificationPreferences_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "UserQualityProfiles",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: true),
SonarrQualityProfileAnime = table.Column<int>(nullable: false),
SonarrRootPathAnime = table.Column<int>(nullable: false),
SonarrRootPath = table.Column<int>(nullable: false),
SonarrQualityProfile = table.Column<int>(nullable: false),
RadarrRootPath = table.Column<int>(nullable: false),
RadarrQualityProfile = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserQualityProfiles", x => x.Id);
table.ForeignKey(
name: "FK_UserQualityProfiles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Votes",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RequestId = table.Column<int>(nullable: false),
VoteType = table.Column<int>(nullable: false),
RequestType = table.Column<int>(nullable: false),
UserId = table.Column<string>(nullable: true),
Date = table.Column<DateTime>(nullable: false),
Deleted = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Votes", x => x.Id);
table.ForeignKey(
name: "FK_Votes_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ChildRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(nullable: true),
Approved = table.Column<bool>(nullable: false),
MarkedAsApproved = table.Column<DateTime>(nullable: false),
RequestedDate = table.Column<DateTime>(nullable: false),
Available = table.Column<bool>(nullable: false),
MarkedAsAvailable = table.Column<DateTime>(nullable: true),
RequestedUserId = table.Column<string>(nullable: true),
Denied = table.Column<bool>(nullable: true),
MarkedAsDenied = table.Column<DateTime>(nullable: false),
DeniedReason = table.Column<string>(nullable: true),
RequestType = table.Column<int>(nullable: false),
RequestedByAlias = table.Column<string>(nullable: true),
ParentRequestId = table.Column<int>(nullable: false),
IssueId = table.Column<int>(nullable: true),
SeriesType = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChildRequests", x => x.Id);
table.ForeignKey(
name: "FK_ChildRequests_TvRequests_ParentRequestId",
column: x => x.ParentRequestId,
principalTable: "TvRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChildRequests_AspNetUsers_RequestedUserId",
column: x => x.RequestedUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Issues",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(nullable: true),
RequestType = table.Column<int>(nullable: false),
ProviderId = table.Column<string>(nullable: true),
RequestId = table.Column<int>(nullable: true),
Subject = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true),
IssueCategoryId = table.Column<int>(nullable: false),
Status = table.Column<int>(nullable: false),
ResovledDate = table.Column<DateTime>(nullable: true),
UserReportedId = table.Column<string>(nullable: true),
IssueId = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Issues", x => x.Id);
table.ForeignKey(
name: "FK_Issues_IssueCategory_IssueCategoryId",
column: x => x.IssueCategoryId,
principalTable: "IssueCategory",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Issues_ChildRequests_IssueId",
column: x => x.IssueId,
principalTable: "ChildRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Issues_MovieRequests_IssueId",
column: x => x.IssueId,
principalTable: "MovieRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Issues_AspNetUsers_UserReportedId",
column: x => x.UserReportedId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "SeasonRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
SeasonNumber = table.Column<int>(nullable: false),
ChildRequestId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SeasonRequests", x => x.Id);
table.ForeignKey(
name: "FK_SeasonRequests_ChildRequests_ChildRequestId",
column: x => x.ChildRequestId,
principalTable: "ChildRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IssueComments",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: true),
Comment = table.Column<string>(nullable: true),
IssuesId = table.Column<int>(nullable: true),
Date = table.Column<DateTime>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IssueComments", x => x.Id);
table.ForeignKey(
name: "FK_IssueComments_Issues_IssuesId",
column: x => x.IssuesId,
principalTable: "Issues",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_IssueComments_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "EpisodeRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
EpisodeNumber = table.Column<int>(nullable: false),
Title = table.Column<string>(nullable: true),
AirDate = table.Column<DateTime>(nullable: false),
Url = table.Column<string>(nullable: true),
Available = table.Column<bool>(nullable: false),
Approved = table.Column<bool>(nullable: false),
Requested = table.Column<bool>(nullable: false),
SeasonId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EpisodeRequests", x => x.Id);
table.ForeignKey(
name: "FK_EpisodeRequests_SeasonRequests_SeasonId",
column: x => x.SeasonId,
principalTable: "SeasonRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AlbumRequests_RequestedUserId",
table: "AlbumRequests",
column: "RequestedUserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId",
table: "AspNetUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserLogins_UserId",
table: "AspNetUserLogins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ChildRequests_ParentRequestId",
table: "ChildRequests",
column: "ParentRequestId");
migrationBuilder.CreateIndex(
name: "IX_ChildRequests_RequestedUserId",
table: "ChildRequests",
column: "RequestedUserId");
migrationBuilder.CreateIndex(
name: "IX_EpisodeRequests_SeasonId",
table: "EpisodeRequests",
column: "SeasonId");
migrationBuilder.CreateIndex(
name: "IX_IssueComments_IssuesId",
table: "IssueComments",
column: "IssuesId");
migrationBuilder.CreateIndex(
name: "IX_IssueComments_UserId",
table: "IssueComments",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Issues_IssueCategoryId",
table: "Issues",
column: "IssueCategoryId");
migrationBuilder.CreateIndex(
name: "IX_Issues_IssueId",
table: "Issues",
column: "IssueId");
migrationBuilder.CreateIndex(
name: "IX_Issues_UserReportedId",
table: "Issues",
column: "UserReportedId");
migrationBuilder.CreateIndex(
name: "IX_MovieRequests_RequestedUserId",
table: "MovieRequests",
column: "RequestedUserId");
migrationBuilder.CreateIndex(
name: "IX_NotificationUserId_UserId",
table: "NotificationUserId",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_RequestLog_UserId",
table: "RequestLog",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_RequestSubscription_UserId",
table: "RequestSubscription",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_SeasonRequests_ChildRequestId",
table: "SeasonRequests",
column: "ChildRequestId");
migrationBuilder.CreateIndex(
name: "IX_Tokens_UserId",
table: "Tokens",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserNotificationPreferences_UserId",
table: "UserNotificationPreferences",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserQualityProfiles_UserId",
table: "UserQualityProfiles",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Votes_UserId",
table: "Votes",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AlbumRequests");
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
migrationBuilder.DropTable(
name: "AspNetUserClaims");
migrationBuilder.DropTable(
name: "AspNetUserLogins");
migrationBuilder.DropTable(
name: "AspNetUserRoles");
migrationBuilder.DropTable(
name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "Audit");
migrationBuilder.DropTable(
name: "EpisodeRequests");
migrationBuilder.DropTable(
name: "IssueComments");
migrationBuilder.DropTable(
name: "NotificationTemplates");
migrationBuilder.DropTable(
name: "NotificationUserId");
migrationBuilder.DropTable(
name: "RecentlyAddedLog");
migrationBuilder.DropTable(
name: "RequestLog");
migrationBuilder.DropTable(
name: "RequestQueue");
migrationBuilder.DropTable(
name: "RequestSubscription");
migrationBuilder.DropTable(
name: "Tokens");
migrationBuilder.DropTable(
name: "UserNotificationPreferences");
migrationBuilder.DropTable(
name: "UserQualityProfiles");
migrationBuilder.DropTable(
name: "Votes");
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(
name: "SeasonRequests");
migrationBuilder.DropTable(
name: "Issues");
migrationBuilder.DropTable(
name: "PlexServerContent");
migrationBuilder.DropTable(
name: "IssueCategory");
migrationBuilder.DropTable(
name: "ChildRequests");
migrationBuilder.DropTable(
name: "MovieRequests");
migrationBuilder.DropTable(
name: "TvRequests");
migrationBuilder.DropTable(
name: "AspNetUsers");
}
}
}

@ -0,0 +1,897 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context;
using Ombi.Store.Context.MySql;
namespace Ombi.Store.Migrations.OmbiMySql
{
[DbContext(typeof(OmbiMySqlContext))]
partial class OmbiMySqlContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("Ombi.Store.Entities.Audit", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AuditArea");
b.Property<int>("AuditType");
b.Property<DateTime>("DateTime");
b.Property<string>("Description");
b.Property<string>("User");
b.HasKey("Id");
b.ToTable("Audit");
});
modelBuilder.Entity("Ombi.Store.Entities.NotificationTemplates", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Agent");
b.Property<bool>("Enabled");
b.Property<string>("Message");
b.Property<int>("NotificationType");
b.Property<string>("Subject");
b.HasKey("Id");
b.ToTable("NotificationTemplates");
});
modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("AddedAt");
b.Property<string>("PlayerId");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("NotificationUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("Alias");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("EmbyConnectUserId");
b.Property<int?>("EpisodeRequestLimit");
b.Property<DateTime?>("LastLoggedIn");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<int?>("MovieRequestLimit");
b.Property<int?>("MusicRequestLimit");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("ProviderUserId");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserAccessToken");
b.Property<string>("UserName")
.HasMaxLength(256);
b.Property<int>("UserType");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Ombi.Store.Entities.RecentlyAddedLog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("AddedAt");
b.Property<string>("AlbumId");
b.Property<int>("ContentId");
b.Property<int>("ContentType");
b.Property<int?>("EpisodeNumber");
b.Property<int?>("SeasonNumber");
b.Property<int>("Type");
b.HasKey("Id");
b.ToTable("RecentlyAddedLog");
});
modelBuilder.Entity("Ombi.Store.Entities.RequestQueue", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime?>("Completed");
b.Property<DateTime>("Dts");
b.Property<string>("Error");
b.Property<int>("RequestId");
b.Property<int>("RetryCount");
b.Property<int>("Type");
b.HasKey("Id");
b.ToTable("RequestQueue");
});
modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("RequestId");
b.Property<int>("RequestType");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("RequestSubscription");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Approved");
b.Property<string>("ArtistName");
b.Property<bool>("Available");
b.Property<string>("Cover");
b.Property<bool?>("Denied");
b.Property<string>("DeniedReason");
b.Property<string>("Disk");
b.Property<string>("ForeignAlbumId");
b.Property<string>("ForeignArtistId");
b.Property<DateTime>("MarkedAsApproved");
b.Property<DateTime?>("MarkedAsAvailable");
b.Property<DateTime>("MarkedAsDenied");
b.Property<decimal>("Rating");
b.Property<DateTime>("ReleaseDate");
b.Property<int>("RequestType");
b.Property<string>("RequestedByAlias");
b.Property<DateTime>("RequestedDate");
b.Property<string>("RequestedUserId");
b.Property<string>("Title");
b.HasKey("Id");
b.HasIndex("RequestedUserId");
b.ToTable("AlbumRequests");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Approved");
b.Property<bool>("Available");
b.Property<bool?>("Denied");
b.Property<string>("DeniedReason");
b.Property<int?>("IssueId");
b.Property<DateTime>("MarkedAsApproved");
b.Property<DateTime?>("MarkedAsAvailable");
b.Property<DateTime>("MarkedAsDenied");
b.Property<int>("ParentRequestId");
b.Property<int>("RequestType");
b.Property<string>("RequestedByAlias");
b.Property<DateTime>("RequestedDate");
b.Property<string>("RequestedUserId");
b.Property<int>("SeriesType");
b.Property<string>("Title");
b.HasKey("Id");
b.HasIndex("ParentRequestId");
b.HasIndex("RequestedUserId");
b.ToTable("ChildRequests");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueCategory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Value");
b.HasKey("Id");
b.ToTable("IssueCategory");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Comment");
b.Property<DateTime>("Date");
b.Property<int?>("IssuesId");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("IssuesId");
b.HasIndex("UserId");
b.ToTable("IssueComments");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Description");
b.Property<int>("IssueCategoryId");
b.Property<int?>("IssueId");
b.Property<string>("ProviderId");
b.Property<int?>("RequestId");
b.Property<int>("RequestType");
b.Property<DateTime?>("ResovledDate");
b.Property<int>("Status");
b.Property<string>("Subject");
b.Property<string>("Title");
b.Property<string>("UserReportedId");
b.HasKey("Id");
b.HasIndex("IssueCategoryId");
b.HasIndex("IssueId");
b.HasIndex("UserReportedId");
b.ToTable("Issues");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Approved");
b.Property<bool>("Available");
b.Property<string>("Background");
b.Property<bool?>("Denied");
b.Property<string>("DeniedReason");
b.Property<DateTime?>("DigitalReleaseDate");
b.Property<string>("ImdbId");
b.Property<int?>("IssueId");
b.Property<string>("LangCode");
b.Property<DateTime>("MarkedAsApproved");
b.Property<DateTime?>("MarkedAsAvailable");
b.Property<DateTime>("MarkedAsDenied");
b.Property<string>("Overview");
b.Property<string>("PosterPath");
b.Property<int>("QualityOverride");
b.Property<DateTime>("ReleaseDate");
b.Property<int>("RequestType");
b.Property<string>("RequestedByAlias");
b.Property<DateTime>("RequestedDate");
b.Property<string>("RequestedUserId");
b.Property<int>("RootPathOverride");
b.Property<string>("Status");
b.Property<int>("TheMovieDbId");
b.Property<string>("Title");
b.HasKey("Id");
b.HasIndex("RequestedUserId");
b.ToTable("MovieRequests");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("EpisodeCount");
b.Property<DateTime>("RequestDate");
b.Property<int>("RequestId");
b.Property<int>("RequestType");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("RequestLog");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Background");
b.Property<string>("ImdbId");
b.Property<string>("Overview");
b.Property<string>("PosterPath");
b.Property<int?>("QualityOverride");
b.Property<DateTime>("ReleaseDate");
b.Property<int?>("RootFolder");
b.Property<string>("Status");
b.Property<string>("Title");
b.Property<int>("TotalSeasons");
b.Property<int>("TvDbId");
b.HasKey("Id");
b.ToTable("TvRequests");
});
modelBuilder.Entity("Ombi.Store.Entities.Tokens", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Token");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Tokens");
});
modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Agent");
b.Property<bool>("Enabled");
b.Property<string>("UserId");
b.Property<string>("Value");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("UserNotificationPreferences");
});
modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("RadarrQualityProfile");
b.Property<int>("RadarrRootPath");
b.Property<int>("SonarrQualityProfile");
b.Property<int>("SonarrQualityProfileAnime");
b.Property<int>("SonarrRootPath");
b.Property<int>("SonarrRootPathAnime");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("UserQualityProfiles");
});
modelBuilder.Entity("Ombi.Store.Entities.Votes", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("Date");
b.Property<bool>("Deleted");
b.Property<int>("RequestId");
b.Property<int>("RequestType");
b.Property<string>("UserId");
b.Property<int>("VoteType");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Votes");
});
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("AirDate");
b.Property<bool>("Approved");
b.Property<bool>("Available");
b.Property<int>("EpisodeNumber");
b.Property<bool>("Requested");
b.Property<int>("SeasonId");
b.Property<string>("Title");
b.Property<string>("Url");
b.HasKey("Id");
b.HasIndex("SeasonId");
b.ToTable("EpisodeRequests");
});
modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("ChildRequestId");
b.Property<int>("SeasonNumber");
b.HasKey("Id");
b.HasIndex("ChildRequestId");
b.ToTable("SeasonRequests");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Ombi.Store.Entities.OmbiUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany("NotificationUserIds")
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser")
.WithMany()
.HasForeignKey("RequestedUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b =>
{
b.HasOne("Ombi.Store.Entities.Requests.TvRequests", "ParentRequest")
.WithMany("ChildRequests")
.HasForeignKey("ParentRequestId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser")
.WithMany()
.HasForeignKey("RequestedUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b =>
{
b.HasOne("Ombi.Store.Entities.Requests.Issues", "Issues")
.WithMany("Comments")
.HasForeignKey("IssuesId");
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b =>
{
b.HasOne("Ombi.Store.Entities.Requests.IssueCategory", "IssueCategory")
.WithMany()
.HasForeignKey("IssueCategoryId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Ombi.Store.Entities.Requests.ChildRequests")
.WithMany("Issues")
.HasForeignKey("IssueId");
b.HasOne("Ombi.Store.Entities.Requests.MovieRequests")
.WithMany("Issues")
.HasForeignKey("IssueId");
b.HasOne("Ombi.Store.Entities.OmbiUser", "UserReported")
.WithMany()
.HasForeignKey("UserReportedId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser")
.WithMany()
.HasForeignKey("RequestedUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Tokens", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany("UserNotificationPreferences")
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Votes", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
{
b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season")
.WithMany("Episodes")
.HasForeignKey("SeasonId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b =>
{
b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", "ChildRequest")
.WithMany("SeasonRequests")
.HasForeignKey("ChildRequestId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,51 @@
// <auto-generated />
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.SettingsMySql
{
[DbContext(typeof(SettingsMySqlContext))]
[Migration("20191103205915_Inital")]
partial class Inital
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
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
}
}
}

@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.SettingsMySql
{
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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,49 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context.MySql;
namespace Ombi.Store.Migrations.SettingsMySql
{
[DbContext(typeof(SettingsMySqlContext))]
partial class SettingsMySqlContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
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
}
}
}

@ -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.Sqlite;
namespace Ombi.Store.Migrations.SettingsSqlite
{
[DbContext(typeof(SettingsSqliteContext))]
[Migration("20191103205204_Inital")]
partial class Inital
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
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
}
}
}

@ -0,0 +1,47 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.SettingsSqlite
{
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.Sqlite;
namespace Ombi.Store.Migrations.SettingsSqlite
{
[DbContext(typeof(SettingsSqliteContext))]
partial class SettingsSqliteContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
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
}
}
}

@ -15,9 +15,10 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.6" />
<PackageReference Include="Nito.AsyncEx" Version="5.0.0-pre-05" />
<PackageReference Include="Polly" Version="7.1.0" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="1.1.9" />
<!--<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="1.1.9" />-->
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />

@ -8,12 +8,12 @@ namespace Ombi.Store.Repository
{
public class ApplicationConfigRepository : IApplicationConfigRepository
{
public ApplicationConfigRepository(ISettingsContext ctx)
public ApplicationConfigRepository(SettingsContext ctx)
{
Ctx = ctx;
}
private ISettingsContext Ctx { get; }
private SettingsContext Ctx { get; }
public Task<ApplicationConfiguration> GetAsync(ConfigurationTypes type)
{

@ -9,12 +9,12 @@ namespace Ombi.Store.Repository
{
public class AuditRepository : IAuditRepository
{
public AuditRepository(IOmbiContext ctx)
public AuditRepository(OmbiContext ctx)
{
Ctx = ctx;
}
private IOmbiContext Ctx { get; }
private OmbiContext Ctx { get; }
public async Task Record(AuditType type, AuditArea area, string description)

@ -13,7 +13,7 @@ using Polly;
namespace Ombi.Store.Repository
{
public class BaseRepository<T, U> : IRepository<T> where T : Entity where U : IDbContext
public class BaseRepository<T, U> : IRepository<T> where T : Entity where U : DbContext
{
public BaseRepository(U ctx)
{

@ -38,12 +38,12 @@ namespace Ombi.Store.Repository
public class EmbyContentRepository : ExternalRepository<EmbyContent>, IEmbyContentRepository
{
public EmbyContentRepository(IExternalContext db):base(db)
public EmbyContentRepository(ExternalContext db):base(db)
{
Db = db;
}
private IExternalContext Db { get; }
private ExternalContext Db { get; }
public async Task<EmbyContent> GetByImdbId(string imdbid)

@ -3,9 +3,9 @@ using Ombi.Store.Entities;
namespace Ombi.Store.Repository
{
public class ExternalRepository<T> : BaseRepository<T, IExternalContext>, IExternalRepository<T> where T : Entity
public class ExternalRepository<T> : BaseRepository<T, ExternalContext>, IExternalRepository<T> where T : Entity
{
public ExternalRepository(IExternalContext ctx) : base(ctx)
public ExternalRepository(ExternalContext ctx) : base(ctx)
{
}
}

@ -11,12 +11,12 @@ namespace Ombi.Store.Repository
{
public class NotificationTemplatesRepository : INotificationTemplatesRepository
{
public NotificationTemplatesRepository(IOmbiContext ctx)
public NotificationTemplatesRepository(OmbiContext ctx)
{
Db = ctx;
}
private IOmbiContext Db { get; }
private OmbiContext Db { get; }
public IQueryable<NotificationTemplates> All()
{

@ -39,12 +39,12 @@ namespace Ombi.Store.Repository
public class PlexServerContentRepository : ExternalRepository<PlexServerContent>, IPlexContentRepository
{
public PlexServerContentRepository(IExternalContext db) : base(db)
public PlexServerContentRepository(ExternalContext db) : base(db)
{
Db = db;
}
private IExternalContext Db { get; }
private ExternalContext Db { get; }
public async Task<bool> ContentExists(string providerId)

@ -3,9 +3,9 @@ using Ombi.Store.Entities;
namespace Ombi.Store.Repository
{
public class Repository<T> : BaseRepository<T,IOmbiContext>, IRepository<T> where T : Entity
public class Repository<T> : BaseRepository<T, OmbiContext>, IRepository<T> where T : Entity
{
public Repository(IOmbiContext ctx) : base(ctx)
public Repository(OmbiContext ctx) : base(ctx)
{
}
}

@ -8,7 +8,7 @@ namespace Ombi.Store.Repository.Requests
{
public interface ITvRequestRepository
{
IOmbiContext Db { get; }
OmbiContext Db { get; }
Task<TvRequests> Add(TvRequests request);
Task<ChildRequests> AddChild(ChildRequests request);
Task Delete(TvRequests request);

@ -11,12 +11,12 @@ namespace Ombi.Store.Repository.Requests
{
public class MovieRequestRepository : Repository<MovieRequests>, IMovieRequestRepository
{
public MovieRequestRepository(IOmbiContext ctx) : base(ctx)
public MovieRequestRepository(OmbiContext ctx) : base(ctx)
{
Db = ctx;
}
private IOmbiContext Db { get; }
private OmbiContext Db { get; }
public async Task<MovieRequests> GetRequestAsync(int theMovieDbId)
{

@ -11,12 +11,12 @@ namespace Ombi.Store.Repository.Requests
{
public class MusicRequestRepository : Repository<AlbumRequest>, IMusicRequestRepository
{
public MusicRequestRepository(IOmbiContext ctx) : base(ctx)
public MusicRequestRepository(OmbiContext ctx) : base(ctx)
{
Db = ctx;
}
private IOmbiContext Db { get; }
private OmbiContext Db { get; }
public Task<AlbumRequest> GetRequestAsync(string foreignAlbumId)
{

@ -8,14 +8,14 @@ using Ombi.Store.Entities.Requests;
namespace Ombi.Store.Repository.Requests
{
public class TvRequestRepository : BaseRepository<TvRequests, IOmbiContext>, ITvRequestRepository
public class TvRequestRepository : BaseRepository<TvRequests, OmbiContext>, ITvRequestRepository
{
public TvRequestRepository(IOmbiContext ctx) : base(ctx)
public TvRequestRepository(OmbiContext ctx) : base(ctx)
{
Db = ctx;
}
public IOmbiContext Db { get; }
public OmbiContext Db { get; }
public async Task<TvRequests> GetRequestAsync(int tvDbId)
{
@ -105,13 +105,6 @@ namespace Ombi.Store.Repository.Requests
await InternalSaveChanges();
}
public async Task<TvRequests> Add(TvRequests request)
{
await Db.TvRequests.AddAsync(request);
await InternalSaveChanges();
return request;
}
public async Task<ChildRequests> AddChild(ChildRequests request)
{
await Db.ChildRequests.AddAsync(request);
@ -120,12 +113,6 @@ namespace Ombi.Store.Repository.Requests
return request;
}
public async Task Delete(TvRequests request)
{
Db.TvRequests.Remove(request);
await InternalSaveChanges();
}
public async Task DeleteChild(ChildRequests request)
{
Db.ChildRequests.Remove(request);

@ -12,13 +12,13 @@ namespace Ombi.Store.Repository
{
public class SettingsJsonRepository : ISettingsRepository
{
public SettingsJsonRepository(ISettingsContext ctx, ICacheService mem)
public SettingsJsonRepository(SettingsContext ctx, ICacheService mem)
{
Db = ctx;
_cache = mem;
}
private ISettingsContext Db { get; }
private SettingsContext Db { get; }
private readonly ICacheService _cache;
public GlobalSettings Insert(GlobalSettings entity)

@ -8,14 +8,14 @@ using Ombi.Helpers;
namespace Ombi.Store.Repository
{
public class TokenRepository : BaseRepository<Tokens, IOmbiContext>, ITokenRepository
public class TokenRepository : BaseRepository<Tokens, OmbiContext>, ITokenRepository
{
public TokenRepository(IOmbiContext db) : base(db)
public TokenRepository(OmbiContext db) : base(db)
{
Db = db;
}
private IOmbiContext Db { get; }
private OmbiContext Db { get; }
public async Task CreateToken(Tokens token)
{

@ -36,12 +36,12 @@ namespace Ombi.Store.Repository
{
//public class UserRepository : IUserRepository
//{
// public UserRepository(IOmbiContext ctx)
// public UserRepository(OmbiContext ctx)
// {
// Db = ctx;
// }
// private IOmbiContext Db { get; }
// private OmbiContext Db { get; }
// public async Task<User> GetUser(string username)
// {

@ -192,6 +192,13 @@ export interface IAbout {
osDescription: string;
processArchitecture: string;
applicationBasePath: string;
ombiDatabaseType: string;
externalDatabaseType: string;
settingsDatabaseType: string;
ombiConnectionString: string;
externalConnectionString: string;
settingsConnectionString: string;
storagePath: string;
notSupported: boolean;
}

@ -144,6 +144,7 @@ namespace Ombi.Controllers.V1
/// <summary>
/// Returns similar movies to the movie id passed in
/// </summary>
/// <param name="model">the movie</param>
/// <remarks>
/// We use TheMovieDb as the Movie Provider
/// </remarks>

@ -29,6 +29,7 @@ using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Ombi.Api.Github;
using Ombi.Core.Engine;
using Ombi.Extensions;
using Ombi.Schedule;
using Quartz;
@ -116,6 +117,8 @@ namespace Ombi.Controllers.V1
[HttpGet("about")]
public AboutViewModel About()
{
var dbConfiguration = DatabaseExtensions.GetDatabaseConfiguration();
var storage = StoragePathSingleton.Instance;
var model = new AboutViewModel
{
FrameworkDescription = RuntimeInformation.FrameworkDescription,
@ -123,9 +126,17 @@ namespace Ombi.Controllers.V1
OsDescription = RuntimeInformation.OSDescription,
ProcessArchitecture = RuntimeInformation.ProcessArchitecture.ToString(),
ApplicationBasePath = Directory.GetCurrentDirectory(),
ExternalConnectionString = dbConfiguration.ExternalDatabase.ConnectionString,
ExternalDatabaseType = dbConfiguration.ExternalDatabase.Type,
OmbiConnectionString = dbConfiguration.OmbiDatabase.ConnectionString,
OmbiDatabaseType = dbConfiguration.OmbiDatabase.Type,
SettingsConnectionString = dbConfiguration.SettingsDatabase.ConnectionString,
SettingsDatabaseType = dbConfiguration.SettingsDatabase.Type,
StoragePath = storage.StoragePath.HasValue() ? storage.StoragePath : "None Specified",
NotSupported = Directory.GetCurrentDirectory().Contains("qpkg")
};
var version = AssemblyHelper.GetRuntimeVersion();
var productArray = version.Split('-');
model.Version = productArray[0];
@ -257,8 +268,8 @@ namespace Ombi.Controllers.V1
[AllowAnonymous]
public async Task<string> GetDefaultLanguage()
{
var s = await Get<OmbiSettings>();
return s.DefaultLanguageCode;
var s = await Get<OmbiSettings>();
return s.DefaultLanguageCode;
}
/// <summary>
@ -455,7 +466,7 @@ namespace Ombi.Controllers.V1
[HttpGet("Update")]
public async Task<UpdateSettings> UpdateSettings()
{
var settings = await Get<UpdateSettings>();
var settings = await Get<UpdateSettings>();
return Mapper.Map<UpdateSettingsViewModel>(settings);
}
@ -610,7 +621,7 @@ namespace Ombi.Controllers.V1
Message = $"CRON Expression {body.Expression} is not valid"
};
}
model.Success = true;
return model;
}

@ -0,0 +1,129 @@
using System;
using System.IO;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Ombi.Helpers;
using Ombi.Store.Context;
using Ombi.Store.Context.MySql;
using Ombi.Store.Context.Sqlite;
using SQLitePCL;
namespace Ombi.Extensions
{
public static class DatabaseExtensions
{
public const string SqliteDatabase = "Sqlite";
public const string MySqlDatabase = "MySQL";
public static void ConfigureDatabases(this IServiceCollection services)
{
var configuration = GetDatabaseConfiguration();
// Ombi db
switch (configuration.OmbiDatabase.Type)
{
case var type when type.Equals(SqliteDatabase, StringComparison.InvariantCultureIgnoreCase):
services.AddDbContext<OmbiContext, OmbiSqliteContext>(x => ConfigureSqlite(x, configuration.OmbiDatabase));
break;
case var type when type.Equals(MySqlDatabase, StringComparison.InvariantCultureIgnoreCase):
services.AddDbContext<OmbiContext, OmbiMySqlContext>(x => ConfigureMySql(x, configuration.OmbiDatabase));
break;
}
switch (configuration.ExternalDatabase.Type)
{
case var type when type.Equals(SqliteDatabase, StringComparison.InvariantCultureIgnoreCase):
services.AddDbContext<ExternalContext, ExternalSqliteContext>(x => ConfigureSqlite(x, configuration.ExternalDatabase));
break;
case var type when type.Equals(MySqlDatabase, StringComparison.InvariantCultureIgnoreCase):
services.AddDbContext<ExternalContext, ExternalMySqlContext>(x => ConfigureMySql(x, configuration.ExternalDatabase));
break;
}
switch (configuration.SettingsDatabase.Type)
{
case var type when type.Equals(SqliteDatabase, StringComparison.InvariantCultureIgnoreCase):
services.AddDbContext<SettingsContext, SettingsSqliteContext>(x => ConfigureSqlite(x, configuration.SettingsDatabase));
break;
case var type when type.Equals(MySqlDatabase, StringComparison.InvariantCultureIgnoreCase):
services.AddDbContext<SettingsContext, SettingsMySqlContext>(x => ConfigureMySql(x, configuration.SettingsDatabase));
break;
}
}
public static DatabaseConfiguration GetDatabaseConfiguration()
{
var i = StoragePathSingleton.Instance;
if (string.IsNullOrEmpty(i.StoragePath))
{
i.StoragePath = string.Empty;
}
var databaseFileLocation = Path.Combine(i.StoragePath, "database.json");
var configuration = new DatabaseConfiguration(i.StoragePath);
if (File.Exists(databaseFileLocation))
{
var databaseJson = File.ReadAllText(databaseFileLocation);
if (string.IsNullOrEmpty(databaseJson))
{
throw new Exception("Found 'database.json' but it was empty!");
}
configuration = JsonConvert.DeserializeObject<DatabaseConfiguration>(databaseJson);
}
return configuration;
}
public static void ConfigureSqlite(DbContextOptionsBuilder options, PerDatabaseConfiguration config)
{
SQLitePCL.Batteries.Init();
SQLitePCL.raw.sqlite3_config(raw.SQLITE_CONFIG_MULTITHREAD);
options.UseSqlite(config.ConnectionString);
}
public static void ConfigureMySql(DbContextOptionsBuilder options, PerDatabaseConfiguration config)
{
options.UseMySql(config.ConnectionString);
}
public class DatabaseConfiguration
{
public DatabaseConfiguration()
{
}
public DatabaseConfiguration(string defaultSqlitePath)
{
OmbiDatabase = new PerDatabaseConfiguration(SqliteDatabase, $"Data Source={Path.Combine(defaultSqlitePath, "Ombi.db")}");
SettingsDatabase = new PerDatabaseConfiguration(SqliteDatabase, $"Data Source={Path.Combine(defaultSqlitePath, "OmbiSettings.db")}");
ExternalDatabase = new PerDatabaseConfiguration(SqliteDatabase, $"Data Source={Path.Combine(defaultSqlitePath, "OmbiExternal.db")}");
}
public PerDatabaseConfiguration OmbiDatabase { get; set; }
public PerDatabaseConfiguration SettingsDatabase { get; set; }
public PerDatabaseConfiguration ExternalDatabase { get; set; }
}
public class PerDatabaseConfiguration
{
public PerDatabaseConfiguration(string type, string connectionString)
{
Type = type;
ConnectionString = connectionString;
}
// Used in Deserialization
public PerDatabaseConfiguration()
{
}
public string Type { get; set; }
public string ConnectionString { get; set; }
}
}
}

@ -9,6 +9,13 @@
public string OsDescription { get; set; }
public string ProcessArchitecture { get; set; }
public string ApplicationBasePath { get; set; }
public string OmbiDatabaseType { get; set; }
public string ExternalDatabaseType { get; set; }
public string SettingsDatabaseType { get; set; }
public string OmbiConnectionString { get; set; }
public string ExternalConnectionString { get; set; }
public string SettingsConnectionString { get; set; }
public string StoragePath { get; set; }
public bool NotSupported { get; set; }
}
}

@ -65,6 +65,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="ncrontab" Version="3.3.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.6" />
<PackageReference Include="Serilog" Version="2.8.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />

@ -10,13 +10,18 @@ using CommandLine.Text;
using Microsoft.AspNetCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Ombi.Extensions;
using Ombi.Helpers;
using Ombi.Store.Context.MySql;
using Ombi.Store.Context.Sqlite;
namespace Ombi
{
public class Program
{
private static string UrlArgs { get; set; }
public static void Main(string[] args)
{
Console.Title = "Ombi";
@ -51,236 +56,93 @@ namespace Ombi
instance.StoragePath = storagePath ?? string.Empty;
// Check if we need to migrate the settings
DeleteSchedules();
CheckAndMigrate();
var ctx = new SettingsContext();
var config = ctx.ApplicationConfigurations.ToList();
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
var dbBaseUrl = config.FirstOrDefault(x => x.Type == ConfigurationTypes.BaseUrl);
if (url == null)
{
url = new ApplicationConfiguration
{
Type = ConfigurationTypes.Url,
Value = "http://*:5000"
};
using (var tran = ctx.Database.BeginTransaction())
{
ctx.ApplicationConfigurations.Add(url);
ctx.SaveChanges();
tran.Commit();
}
//CheckAndMigrate();
urlValue = url.Value;
}
if (!url.Value.Equals(host))
var services = new ServiceCollection();
services.ConfigureDatabases();
using (var provider = services.BuildServiceProvider())
{
url.Value = UrlArgs;
var settingsDb = provider.GetRequiredService<SettingsContext>();
using (var tran = ctx.Database.BeginTransaction())
{
ctx.SaveChanges();
tran.Commit();
}
urlValue = url.Value;
}
if (dbBaseUrl == null)
{
if (baseUrl.HasValue() && baseUrl.StartsWith("/"))
var config = settingsDb.ApplicationConfigurations.ToList();
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
var dbBaseUrl = config.FirstOrDefault(x => x.Type == ConfigurationTypes.BaseUrl);
if (url == null)
{
dbBaseUrl = new ApplicationConfiguration
url = new ApplicationConfiguration
{
Type = ConfigurationTypes.BaseUrl,
Value = baseUrl
Type = ConfigurationTypes.Url,
Value = "http://*:5000"
};
using (var tran = ctx.Database.BeginTransaction())
using (var tran = settingsDb.Database.BeginTransaction())
{
ctx.ApplicationConfigurations.Add(dbBaseUrl);
ctx.SaveChanges();
settingsDb.ApplicationConfigurations.Add(url);
settingsDb.SaveChanges();
tran.Commit();
}
}
}
else if (baseUrl.HasValue() && !baseUrl.Equals(dbBaseUrl.Value))
{
dbBaseUrl.Value = baseUrl;
using (var tran = ctx.Database.BeginTransaction())
{
ctx.SaveChanges();
tran.Commit();
urlValue = url.Value;
}
}
Console.WriteLine($"We are running on {urlValue}");
CreateHostBuilder(args).Build().Run();
}
private static void DeleteSchedules()
{
try
{
if (File.Exists("Schedules.db"))
if (!url.Value.Equals(host))
{
File.Delete("Schedules.db");
}
}
catch (Exception)
{
}
}
url.Value = UrlArgs;
/// <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;
var ombi = new OmbiContext();
var settings = new SettingsContext();
using (var tran = settingsDb.Database.BeginTransaction())
{
settingsDb.SaveChanges();
tran.Commit();
}
try
{
urlValue = url.Value;
}
using (var tran = settings.Database.BeginTransaction())
if (dbBaseUrl == null)
{
if (ombi.Settings.Any() && !settings.Settings.Any())
if (baseUrl.HasValue() && baseUrl.StartsWith("/"))
{
// OK migrate it!
var allSettings = ombi.Settings.ToList();
settings.Settings.AddRange(allSettings);
doneGlobal = true;
}
dbBaseUrl = new ApplicationConfiguration
{
Type = ConfigurationTypes.BaseUrl,
Value = baseUrl
};
// Check for any application settings
using (var tran = settingsDb.Database.BeginTransaction())
{
settingsDb.ApplicationConfigurations.Add(dbBaseUrl);
settingsDb.SaveChanges();
tran.Commit();
}
}
}
else if (baseUrl.HasValue() && !baseUrl.Equals(dbBaseUrl.Value))
{
dbBaseUrl.Value = baseUrl;
if (ombi.ApplicationConfigurations.Any() && !settings.ApplicationConfigurations.Any())
using (var tran = settingsDb.Database.BeginTransaction())
{
// OK migrate it!
var allSettings = ombi.ApplicationConfigurations.ToList();
settings.ApplicationConfigurations.AddRange(allSettings);
doneConfig = true;
settingsDb.SaveChanges();
tran.Commit();
}
settings.SaveChanges();
tran.Commit();
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
Console.WriteLine($"We are running on {urlValue}");
using (var tran = ombi.Database.BeginTransaction())
{
// Now delete the old stuff
if (doneGlobal)
ombi.Database.ExecuteSqlCommand("DELETE FROM GlobalSettings");
if (doneConfig)
ombi.Database.ExecuteSqlCommand("DELETE FROM ApplicationConfiguration");
tran.Commit();
CreateHostBuilder(args).Build().Run();
}
}
// Now migrate all the external stuff
var external = new ExternalContext();
private static void DeleteSchedules()
{
try
{
using (var tran = external.Database.BeginTransaction())
if (File.Exists("Schedules.db"))
{
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();
tran.Commit();
File.Delete("Schedules.db");
}
}
catch (Exception e)
catch (Exception)
{
Console.WriteLine(e);
throw;
}
}

@ -17,6 +17,7 @@ using Microsoft.Extensions.Logging;
using Ombi.Core.Authentication;
using Ombi.Core.Settings;
using Ombi.DependencyInjection;
using Ombi.Extensions;
using Ombi.Helpers;
using Ombi.Hubs;
using Ombi.Mapping;
@ -77,7 +78,7 @@ namespace Ombi
options.User.AllowedUserNameCharacters = string.Empty;
});
services.ConfigureDatabases();
services.AddHealthChecks();
services.AddMemoryCache();
@ -101,7 +102,6 @@ namespace Ombi
#pragma warning restore ASP0000 // Do not call 'IServiceCollection.BuildServiceProvider' in 'ConfigureServices'
});
SQLitePCL.raw.sqlite3_config(raw.SQLITE_CONFIG_MULTITHREAD);
services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
{
@ -130,7 +130,7 @@ namespace Ombi
serviceProvider.UseQuartz().GetAwaiter().GetResult();
var ctx = serviceProvider.GetService<IOmbiContext>();
var ctx = serviceProvider.GetService<OmbiContext>();
loggerFactory.AddSerilog();
app.UseSpaStaticFiles();
@ -175,10 +175,8 @@ namespace Ombi
{WorkerCount = 1, ServerTimeout = TimeSpan.FromDays(1), ShutdownTimeout = TimeSpan.FromDays(1)});
ctx.Seed();
var settingsctx = serviceProvider.GetService<ISettingsContext>();
var externalctx = serviceProvider.GetService<IExternalContext>();
var settingsctx = serviceProvider.GetService<SettingsContext>();
settingsctx.Seed();
externalctx.Seed();
var provider = new FileExtensionContentTypeProvider {Mappings = {[".map"] = "application/octet-stream"}};

Loading…
Cancel
Save