Fixed migration issue

This commit is contained in:
kay.one 2011-06-04 23:35:03 -07:00
parent 57690f49a0
commit 72af060d68
2 changed files with 18 additions and 11 deletions

View File

@ -57,7 +57,6 @@ namespace NzbDrone.Core
LogConfiguration.Setup();
Migrations.Run(Connection.MainConnectionString, true);
ForceMigration(_kernel.Get<IRepository>());
SetupDefaultQualityProfiles(_kernel.Get<IRepository>()); //Setup the default QualityProfiles on start-up
@ -134,16 +133,6 @@ namespace NzbDrone.Core
_kernel.Get<ExternalNotificationProvider>().InitializeNotifiers(notifiers.ToList());
}
private static void ForceMigration(IRepository repository)
{
repository.All<Series>().Count();
repository.All<Episode>().Count();
repository.All<EpisodeFile>().Count();
repository.All<QualityProfile>().Count();
repository.All<History>().Count();
repository.All<IndexerSetting>().Count();
}
/// <summary>
/// Forces IISExpress process to exit with the host application
/// </summary>

View File

@ -7,7 +7,9 @@ using System.Text;
using Migrator.Framework;
using NLog;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Extensions;
using SubSonic.Repository;
using SubSonic.Schema;
namespace NzbDrone.Core.Datastore
@ -36,7 +38,11 @@ namespace NzbDrone.Core.Datastore
migrator.MigrateToLastVersion();
ForceSubSonicMigration(Connection.CreateSimpleRepository(connetionString));
Logger.Info("Database migration completed");
}
catch (Exception e)
{
@ -44,6 +50,16 @@ namespace NzbDrone.Core.Datastore
}
}
public static void ForceSubSonicMigration(IRepository repository)
{
repository.Single<Series>(1);
repository.Single<Episode>(1);
repository.Single<EpisodeFile>(1);
repository.Single<QualityProfile>(1);
repository.Single<History>(1);
repository.Single<IndexerSetting>(1);
}
public static void RemoveDeletedColumns(ITransformationProvider transformationProvider)
{
@ -133,6 +149,8 @@ namespace NzbDrone.Core.Datastore
{
public override void Up()
{
Migrations.ForceSubSonicMigration(Connection.CreateSimpleRepository(Connection.MainConnectionString));
var episodesTable = RepositoryProvider.EpisodesSchema;
//Database.AddIndex("idx_episodes_series_season_episode", episodesTable.Name, true,
// episodesTable.GetColumnByPropertyName("SeriesId").Name,