2012-01-15 08:47:13 +03:00
|
|
|
using System;
|
2013-02-17 02:29:21 +03:00
|
|
|
using System.Data.Common;
|
2013-02-16 22:23:31 +03:00
|
|
|
using System.Data.SqlClient;
|
2012-01-15 08:47:13 +03:00
|
|
|
using System.Linq;
|
2013-02-17 02:29:21 +03:00
|
|
|
using System.Reflection;
|
2012-01-15 08:47:13 +03:00
|
|
|
using Migrator.Framework;
|
|
|
|
using NzbDrone.Common;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Datastore.Migrations
|
|
|
|
{
|
|
|
|
public abstract class NzbDroneMigration : Migration
|
|
|
|
{
|
|
|
|
protected virtual void MainDbUpgrade()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void LogDbUpgrade()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Up()
|
|
|
|
{
|
2013-02-04 04:27:34 +03:00
|
|
|
if (Database.ConnectionString.Contains(PathExtentions.NZBDRONE_SQLCE_DB_FILE))
|
2012-01-15 08:47:13 +03:00
|
|
|
{
|
|
|
|
MainDbUpgrade();
|
|
|
|
}
|
2013-02-04 04:27:34 +03:00
|
|
|
else if (Database.ConnectionString.Contains(PathExtentions.LOG_SQLCE_DB_FILE))
|
2012-01-15 08:47:13 +03:00
|
|
|
{
|
|
|
|
LogDbUpgrade();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LogDbUpgrade();
|
|
|
|
MainDbUpgrade();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-17 04:52:40 +03:00
|
|
|
protected IObjectDatabase GetObjectDb()
|
2013-02-04 07:18:59 +03:00
|
|
|
{
|
2013-02-17 02:29:21 +03:00
|
|
|
var sqlCeConnection = SqlCeProxy.EnsureDatabase(Database.ConnectionString);
|
|
|
|
|
2013-02-04 07:18:59 +03:00
|
|
|
var eqPath = sqlCeConnection.Database.Replace(".sdf", ".eq");
|
2013-02-17 07:59:35 +03:00
|
|
|
return new SiaqoDbFactory(new DiskProvider(),new EnvironmentProvider()).Create(eqPath);
|
2013-02-04 07:18:59 +03:00
|
|
|
}
|
2012-01-15 08:47:13 +03:00
|
|
|
|
|
|
|
public override void Down()
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|