Fixed the migration

This commit is contained in:
TidusJar 2018-10-04 21:04:25 +01:00
parent a40af63a9c
commit 5ecceec06e
3 changed files with 21 additions and 14 deletions

View file

@ -17,6 +17,7 @@ namespace Ombi.Store.Context
} }
public DbSet<PlexServerContent> PlexServerContent { get; set; } public DbSet<PlexServerContent> PlexServerContent { get; set; }
public DbSet<PlexSeasonsContent> PlexSeasonsContent { get; set; }
public DbSet<PlexEpisode> PlexEpisode { get; set; } public DbSet<PlexEpisode> PlexEpisode { get; set; }
public DbSet<RadarrCache> RadarrCache { get; set; } public DbSet<RadarrCache> RadarrCache { get; set; }
public DbSet<CouchPotatoCache> CouchPotatoCache { get; set; } public DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
@ -37,7 +38,7 @@ namespace Ombi.Store.Context
{ {
i.StoragePath = string.Empty; i.StoragePath = string.Empty;
} }
optionsBuilder.UseSqlite($"Data Source={Path.Combine(i.StoragePath, "ExternalOmbi.db")}"); optionsBuilder.UseSqlite($"Data Source={Path.Combine(i.StoragePath, "OmbiExternal.db")}");
} }
protected override void OnModelCreating(ModelBuilder builder) protected override void OnModelCreating(ModelBuilder builder)

View file

@ -24,6 +24,7 @@ namespace Ombi.Store.Context
public DbSet<NotificationTemplates> NotificationTemplates { get; set; } public DbSet<NotificationTemplates> NotificationTemplates { get; set; }
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; } public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
public DbSet<PlexServerContent> PlexServerContent { get; set; } public DbSet<PlexServerContent> PlexServerContent { get; set; }
public DbSet<PlexSeasonsContent> PlexSeasonsContent { get; set; }
public DbSet<PlexEpisode> PlexEpisode { get; set; } public DbSet<PlexEpisode> PlexEpisode { get; set; }
public DbSet<GlobalSettings> Settings { get; set; } public DbSet<GlobalSettings> Settings { get; set; }
public DbSet<RadarrCache> RadarrCache { get; set; } public DbSet<RadarrCache> RadarrCache { get; set; }

View file

@ -144,9 +144,9 @@ namespace Ombi
// Now delete the old stuff // Now delete the old stuff
if (doneGlobal) if (doneGlobal)
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE GlobalSettings"); ombi.Database.ExecuteSqlCommand("DELETE FROM GlobalSettings");
if (doneConfig) if (doneConfig)
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE ApplicationConfiguration"); ombi.Database.ExecuteSqlCommand("DELETE FROM ApplicationConfiguration");
} }
@ -160,59 +160,64 @@ namespace Ombi
if (ombi.PlexEpisode.Any()) if (ombi.PlexEpisode.Any())
{ {
external.PlexEpisode.AddRange(ombi.PlexEpisode.ToList()); external.PlexEpisode.AddRange(ombi.PlexEpisode.ToList());
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE PlexEpisode"); 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()) if (ombi.PlexServerContent.Any())
{ {
external.PlexServerContent.AddRange(ombi.PlexServerContent.ToList()); external.PlexServerContent.AddRange(ombi.PlexServerContent.ToList());
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE PlexServerContent"); ombi.Database.ExecuteSqlCommand("DELETE FROM PlexServerContent");
} }
if (ombi.EmbyEpisode.Any()) if (ombi.EmbyEpisode.Any())
{ {
external.EmbyEpisode.AddRange(ombi.EmbyEpisode.ToList()); external.EmbyEpisode.AddRange(ombi.EmbyEpisode.ToList());
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE EmbyEpisode"); ombi.Database.ExecuteSqlCommand("DELETE FROM EmbyEpisode");
} }
if (ombi.EmbyContent.Any()) if (ombi.EmbyContent.Any())
{ {
external.EmbyContent.AddRange(ombi.EmbyContent.ToList()); external.EmbyContent.AddRange(ombi.EmbyContent.ToList());
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE EmbyContent"); ombi.Database.ExecuteSqlCommand("DELETE FROM EmbyContent");
} }
if (ombi.RadarrCache.Any()) if (ombi.RadarrCache.Any())
{ {
external.RadarrCache.AddRange(ombi.RadarrCache.ToList()); external.RadarrCache.AddRange(ombi.RadarrCache.ToList());
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE RadarrCache"); ombi.Database.ExecuteSqlCommand("DELETE FROM RadarrCache");
} }
if (ombi.SonarrCache.Any()) if (ombi.SonarrCache.Any())
{ {
external.SonarrCache.AddRange(ombi.SonarrCache.ToList()); external.SonarrCache.AddRange(ombi.SonarrCache.ToList());
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE SonarrCache"); ombi.Database.ExecuteSqlCommand("DELETE FROM SonarrCache");
} }
if (ombi.LidarrAlbumCache.Any()) if (ombi.LidarrAlbumCache.Any())
{ {
external.LidarrAlbumCache.AddRange(ombi.LidarrAlbumCache.ToList()); external.LidarrAlbumCache.AddRange(ombi.LidarrAlbumCache.ToList());
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE LidarrAlbumCache"); ombi.Database.ExecuteSqlCommand("DELETE FROM LidarrAlbumCache");
} }
if (ombi.LidarrArtistCache.Any()) if (ombi.LidarrArtistCache.Any())
{ {
external.LidarrArtistCache.AddRange(ombi.LidarrArtistCache.ToList()); external.LidarrArtistCache.AddRange(ombi.LidarrArtistCache.ToList());
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE LidarrArtistCache"); ombi.Database.ExecuteSqlCommand("DELETE FROM LidarrArtistCache");
} }
if (ombi.SickRageEpisodeCache.Any()) if (ombi.SickRageEpisodeCache.Any())
{ {
external.SickRageEpisodeCache.AddRange(ombi.SickRageEpisodeCache.ToList()); external.SickRageEpisodeCache.AddRange(ombi.SickRageEpisodeCache.ToList());
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE SickRageEpisodeCache"); ombi.Database.ExecuteSqlCommand("DELETE FROM SickRageEpisodeCache");
} }
if (ombi.SickRageCache.Any()) if (ombi.SickRageCache.Any())
{ {
external.SickRageCache.AddRange(ombi.SickRageCache.ToList()); external.SickRageCache.AddRange(ombi.SickRageCache.ToList());
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE SickRageCache"); ombi.Database.ExecuteSqlCommand("DELETE FROM SickRageCache");
} }
if (ombi.CouchPotatoCache.Any()) if (ombi.CouchPotatoCache.Any())
{ {
external.CouchPotatoCache.AddRange(ombi.CouchPotatoCache.ToList()); external.CouchPotatoCache.AddRange(ombi.CouchPotatoCache.ToList());
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE CouchPotatoCache"); ombi.Database.ExecuteSqlCommand("DELETE FROM CouchPotatoCache");
} }
external.SaveChanges(); external.SaveChanges();