Got MySql working

This commit is contained in:
tidusjar 2019-11-03 00:02:10 +00:00
commit 1a086e6f19
22 changed files with 6443 additions and 79 deletions

View file

@ -12,12 +12,9 @@ namespace Ombi.Store.Context
{
public abstract class OmbiContext : IdentityDbContext<OmbiUser>
{
private static bool _created;
protected OmbiContext(DbContextOptions<OmbiContext> options) : base(options)
{
if (_created) return;
_created = true;
}
/// <summary>
@ -33,15 +30,6 @@ namespace Ombi.Store.Context
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; }
@ -58,16 +46,25 @@ 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 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()
{

View file

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

View file

@ -1,5 +1,4 @@
using Microsoft.EntityFrameworkCore;
using Ombi.Store.Entities;
namespace Ombi.Store.Context
{
@ -15,21 +14,5 @@ namespace Ombi.Store.Context
Database.SetCommandTimeout(60);
Database.Migrate();
}
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);
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -15,9 +15,10 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<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>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />

View file

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