Finished it!

pull/3241/head
tidusjar 5 years ago
parent 1a086e6f19
commit 560c3c3ead

@ -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)
{

@ -136,12 +136,12 @@ namespace Ombi.DependencyInjection
public static void RegisterStore(this IServiceCollection services) {
//services.AddDbContext<OmbiContext>();
services.AddDbContext<SettingsContext>();
services.AddDbContext<ExternalContext>();
//services.AddDbContext<SettingsContext>();
//services.AddDbContext<ExternalContext>();
//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<IExternalContext, ExternalContext>(); // 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>();

@ -43,7 +43,7 @@ namespace Ombi.Schedule.Jobs.Couchpotato
public class CouchPotatoSync : ICouchPotatoSync
{
public CouchPotatoSync(ISettingsService<CouchPotatoSettings> cpSettings,
ICouchPotatoApi api, ILogger<CouchPotatoSync> log, IExternalContext ctx)
ICouchPotatoApi api, ILogger<CouchPotatoSync> log, ExternalContext ctx)
{
_settings = cpSettings;
_api = api;
@ -55,7 +55,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;
public async Task Execute(IJobExecutionContext job)
{

@ -17,7 +17,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)
{
_lidarrSettings = lidarr;
@ -31,7 +31,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;

@ -18,7 +18,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,
IBackgroundJobClient background, ILidarrAlbumSync album)
{
_lidarrSettings = lidarr;
@ -32,7 +32,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 ILidarrAlbumSync _albumSync;

@ -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,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();
}
}
}

@ -1,7 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Ombi.Store.Entities;
namespace Ombi.Store.Context
namespace Ombi.Store.Context.MySql
{
public sealed class OmbiMySqlContext : OmbiContext
{

@ -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();
}
}
}

@ -50,21 +50,6 @@ namespace Ombi.Store.Context
public DbSet<UserNotificationPreferences> UserNotificationPreferences { get; set; }
public DbSet<UserQualityProfiles> UserQualityProfileses { get; set; }
public DbSet<RequestQueue> RequestQueue { get; set; }
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,32 @@
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,17 @@
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;
Database.SetCommandTimeout(60);
Database.Migrate();
}
}
}

@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context
namespace Ombi.Store.Context.Sqlite
{
public sealed class OmbiSqliteContext : OmbiContext
{

@ -0,0 +1,17 @@
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;
Database.SetCommandTimeout(60);
Database.Migrate();
}
}
}

@ -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
}
}
}

@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context;
using Ombi.Store.Context.MySql;
namespace Ombi.Store.Migrations.OmbiMySql
{

@ -4,6 +4,7 @@ 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
{

@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context;
using Ombi.Store.Context.Sqlite;
namespace Ombi.Store.Migrations.OmbiSqlite
{

@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context;
using Ombi.Store.Context.Sqlite;
namespace Ombi.Store.Migrations.OmbiSqlite
{

@ -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
}
}
}

@ -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)
{

@ -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)

@ -5,6 +5,8 @@ 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
@ -12,8 +14,8 @@ namespace Ombi.Extensions
public static class DatabaseExtensions
{
private const string SqliteDatabase = "Sqlite";
private const string MySqlDatabase = "MySQL";
public const string SqliteDatabase = "Sqlite";
public const string MySqlDatabase = "MySQL";
public static void ConfigureDatabases(this IServiceCollection services)
{
@ -36,9 +38,29 @@ namespace Ombi.Extensions
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;
}
}
private static DatabaseConfiguration GetDatabaseConfiguration(string databaseFileLocation, string storagePath)
public static DatabaseConfiguration GetDatabaseConfiguration(string databaseFileLocation, string storagePath)
{
var configuration = new DatabaseConfiguration(storagePath);
if (File.Exists(databaseFileLocation))
@ -55,7 +77,7 @@ namespace Ombi.Extensions
return configuration;
}
private static void ConfigureSqlite(DbContextOptionsBuilder options, PerDatabaseConfiguration config)
public static void ConfigureSqlite(DbContextOptionsBuilder options, PerDatabaseConfiguration config)
{
SQLitePCL.Batteries.Init();
SQLitePCL.raw.sqlite3_config(raw.SQLITE_CONFIG_MULTITHREAD);
@ -63,12 +85,12 @@ namespace Ombi.Extensions
options.UseSqlite(config.ConnectionString);
}
private static void ConfigureMySql(DbContextOptionsBuilder options, PerDatabaseConfiguration config)
public static void ConfigureMySql(DbContextOptionsBuilder options, PerDatabaseConfiguration config)
{
options.UseMySql(config.ConnectionString);
}
private class DatabaseConfiguration
public class DatabaseConfiguration
{
public DatabaseConfiguration()
{
@ -78,15 +100,15 @@ namespace Ombi.Extensions
public DatabaseConfiguration(string defaultSqlitePath)
{
OmbiDatabase = new PerDatabaseConfiguration(SqliteDatabase, $"Data Source={Path.Combine(defaultSqlitePath, "Ombi.db")}");
SettingsDatabase = new PerDatabaseConfiguration(SqliteDatabase, $"Data Source={Path.Combine(defaultSqlitePath, "Settings.db")}");
ExternalDatabase = new PerDatabaseConfiguration(SqliteDatabase, $"Data Source={Path.Combine(defaultSqlitePath, "External.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; }
}
private class PerDatabaseConfiguration
public class PerDatabaseConfiguration
{
public PerDatabaseConfiguration(string type, string connectionString)
{

@ -9,13 +9,18 @@ using CommandLine;
using CommandLine.Text;
using Microsoft.AspNetCore;
using Microsoft.EntityFrameworkCore;
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,71 +56,79 @@ namespace Ombi
// 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();
}
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())
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)
{
ctx.SaveChanges();
tran.Commit();
}
url = new ApplicationConfiguration
{
Type = ConfigurationTypes.Url,
Value = "http://*:5000"
};
using (var tran = settingsDb.Database.BeginTransaction())
{
settingsDb.ApplicationConfigurations.Add(url);
settingsDb.SaveChanges();
tran.Commit();
}
urlValue = url.Value;
}
urlValue = url.Value;
}
if (dbBaseUrl == null)
{
if (baseUrl.HasValue() && baseUrl.StartsWith("/"))
if (!url.Value.Equals(host))
{
dbBaseUrl = new ApplicationConfiguration
{
Type = ConfigurationTypes.BaseUrl,
Value = baseUrl
};
url.Value = UrlArgs;
using (var tran = ctx.Database.BeginTransaction())
using (var tran = settingsDb.Database.BeginTransaction())
{
ctx.ApplicationConfigurations.Add(dbBaseUrl);
ctx.SaveChanges();
settingsDb.SaveChanges();
tran.Commit();
}
urlValue = url.Value;
}
}
else if (baseUrl.HasValue() && !baseUrl.Equals(dbBaseUrl.Value))
{
dbBaseUrl.Value = baseUrl;
using (var tran = ctx.Database.BeginTransaction())
if (dbBaseUrl == null)
{
ctx.SaveChanges();
tran.Commit();
if (baseUrl.HasValue() && baseUrl.StartsWith("/"))
{
dbBaseUrl = new ApplicationConfiguration
{
Type = ConfigurationTypes.BaseUrl,
Value = baseUrl
};
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;
Console.WriteLine($"We are running on {urlValue}");
using (var tran = settingsDb.Database.BeginTransaction())
{
settingsDb.SaveChanges();
tran.Commit();
}
}
Console.WriteLine($"We are running on {urlValue}");
CreateWebHostBuilder(args).Build().Run();
CreateWebHostBuilder(args).Build().Run();
}
}
private static void DeleteSchedules()
@ -132,157 +145,6 @@ namespace Ombi
}
}
///// <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();
// try
// {
// using (var tran = settings.Database.BeginTransaction())
// {
// if (ombi.Settings.Any() && !settings.Settings.Any())
// {
// // OK migrate it!
// var allSettings = ombi.Settings.ToList();
// settings.Settings.AddRange(allSettings);
// doneGlobal = true;
// }
// // Check for any application settings
// if (ombi.ApplicationConfigurations.Any() && !settings.ApplicationConfigurations.Any())
// {
// // OK migrate it!
// var allSettings = ombi.ApplicationConfigurations.ToList();
// settings.ApplicationConfigurations.AddRange(allSettings);
// doneConfig = true;
// }
// settings.SaveChanges();
// tran.Commit();
// }
// }
// catch (Exception e)
// {
// Console.WriteLine(e);
// throw;
// }
// 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();
// }
// // Now migrate all the external stuff
// var external = new ExternalContext();
// try
// {
// using (var tran = external.Database.BeginTransaction())
// {
// 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();
// }
// }
// catch (Exception e)
// {
// Console.WriteLine(e);
// throw;
// }
//}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()

@ -192,10 +192,8 @@ namespace Ombi
//var jobSetup = app.ApplicationServices.GetService<IJobSetup>();
//jobSetup.Setup();
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