some db/migration cleanup

This commit is contained in:
kay.one 2011-07-07 20:27:11 -07:00
parent 8424dd6ede
commit 15aedfc847
13 changed files with 76 additions and 130 deletions

View File

@ -35,7 +35,7 @@ namespace NzbDrone.Core.Test
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>())) .Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName)); .Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var fakeSettings = Builder<IndexerSetting>.CreateNew().Build(); var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
mocker.GetMock<IndexerProvider>() mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>())) .Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings); .Returns(fakeSettings);
@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test
{ {
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
mocker.Resolve<HttpProvider>(); mocker.Resolve<HttpProvider>();
var fakeSettings = Builder<IndexerSetting>.CreateNew().Build(); var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
mocker.GetMock<IndexerProvider>() mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>())) .Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings); .Returns(fakeSettings);
@ -100,7 +100,7 @@ namespace NzbDrone.Core.Test
const string summary = "My fake summary"; const string summary = "My fake summary";
var fakeSettings = Builder<IndexerSetting>.CreateNew().Build(); var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
mocker.GetMock<IndexerProvider>() mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>())) .Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings); .Returns(fakeSettings);
@ -127,7 +127,7 @@ namespace NzbDrone.Core.Test
const string summary = "My fake summary"; const string summary = "My fake summary";
var fakeSettings = Builder<IndexerSetting>.CreateNew().Build(); var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
mocker.GetMock<IndexerProvider>() mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>())) .Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings); .Returns(fakeSettings);
@ -150,7 +150,7 @@ namespace NzbDrone.Core.Test
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
mocker.SetConstant(new HttpProvider()); mocker.SetConstant(new HttpProvider());
var fakeSettings = Builder<IndexerSetting>.CreateNew().Build(); var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
mocker.GetMock<IndexerProvider>() mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>())) .Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings); .Returns(fakeSettings);

View File

@ -1,32 +0,0 @@
using System;
using System.Data;
using Migrator.Framework;
namespace NzbDrone.Core.Datastore.Migrations
{
[Migration(20110705)]
public class Migration20110705 : Migration
{
public override void Up()
{
//Upgrade column size
Database.ChangeColumn("Series", new Column("Overview", DbType.String, 4000, ColumnProperty.Null));
Database.ChangeColumn("Series", new Column("Path", DbType.String, 4000, ColumnProperty.NotNull));
Database.ChangeColumn("Episodes", new Column("Overview", DbType.String, 4000, ColumnProperty.Null));
Database.ChangeColumn("EpisodeFiles", new Column("Path", DbType.String, 4000, ColumnProperty.NotNull));
Database.ChangeColumn("RootDirs", new Column("Path", DbType.String, 4000, ColumnProperty.NotNull));
Database.ChangeColumn("Logs", new Column("Message", DbType.String, 4000, ColumnProperty.NotNull));
Database.ChangeColumn("Logs", new Column("Exception", DbType.String, 4000, ColumnProperty.Null));
}
public override void Down()
{
throw new NotImplementedException();
}
}
}

View File

@ -5,8 +5,8 @@ using Migrator.Framework;
namespace NzbDrone.Core.Datastore.Migrations namespace NzbDrone.Core.Datastore.Migrations
{ {
[Migration(20110622)] [Migration(20110707)]
public class Migration20110622 : Migration public class Migration20110707 : Migration
{ {
public override void Up() public override void Up()
{ {
@ -16,11 +16,11 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("Title", DbType.String, ColumnProperty.Null), new Column("Title", DbType.String, ColumnProperty.Null),
new Column("CleanTitle", DbType.String, ColumnProperty.Null), new Column("CleanTitle", DbType.String, ColumnProperty.Null),
new Column("Status", DbType.String, ColumnProperty.Null), new Column("Status", DbType.String, ColumnProperty.Null),
new Column("Overview", DbType.String, ColumnProperty.Null), new Column("Overview", DbType.String,4000, ColumnProperty.Null),
new Column("AirsDayOfWeek", DbType.Int32, ColumnProperty.Null), new Column("AirsDayOfWeek", DbType.Int32, ColumnProperty.Null),
new Column("AirTimes", DbType.String, ColumnProperty.Null), new Column("AirTimes", DbType.String, ColumnProperty.Null),
new Column("Language", DbType.String, ColumnProperty.Null), new Column("Language", DbType.String, ColumnProperty.Null),
new Column("Path", DbType.String, ColumnProperty.NotNull), new Column("Path", DbType.String,4000, ColumnProperty.NotNull),
new Column("Monitored", DbType.Boolean, ColumnProperty.NotNull), new Column("Monitored", DbType.Boolean, ColumnProperty.NotNull),
new Column("QualityProfileId", DbType.Int32, ColumnProperty.NotNull), new Column("QualityProfileId", DbType.Int32, ColumnProperty.NotNull),
new Column("SeasonFolder", DbType.Boolean, ColumnProperty.NotNull), new Column("SeasonFolder", DbType.Boolean, ColumnProperty.NotNull),
@ -35,8 +35,8 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull), new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
new Column("SeasonNumber", DbType.Int32, ColumnProperty.NotNull), new Column("SeasonNumber", DbType.Int32, ColumnProperty.NotNull),
new Column("EpisodeNumber", DbType.Int32, ColumnProperty.NotNull), new Column("EpisodeNumber", DbType.Int32, ColumnProperty.NotNull),
new Column("Title", DbType.String, ColumnProperty.Null), new Column("Title", DbType.String,100, ColumnProperty.Null),
new Column("Overview", DbType.String, ColumnProperty.Null), new Column("Overview", DbType.String,4000, ColumnProperty.Null),
new Column("Ignored", DbType.Boolean, ColumnProperty.NotNull), new Column("Ignored", DbType.Boolean, ColumnProperty.NotNull),
new Column("EpisodeFileId", DbType.Int32, ColumnProperty.Null), new Column("EpisodeFileId", DbType.Int32, ColumnProperty.Null),
new Column("AirDate", DbType.DateTime, ColumnProperty.Null), new Column("AirDate", DbType.DateTime, ColumnProperty.Null),
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("EpisodeFileId", DbType.Int32, new Column("EpisodeFileId", DbType.Int32,
ColumnProperty.PrimaryKeyWithIdentity), ColumnProperty.PrimaryKeyWithIdentity),
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull), new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
new Column("Path", DbType.String, ColumnProperty.NotNull), new Column("Path", DbType.String,4000, ColumnProperty.NotNull),
new Column("Quality", DbType.Int32, ColumnProperty.NotNull), new Column("Quality", DbType.Int32, ColumnProperty.NotNull),
new Column("Proper", DbType.Int32, ColumnProperty.NotNull), new Column("Proper", DbType.Int32, ColumnProperty.NotNull),
new Column("Size", DbType.Int64, ColumnProperty.NotNull), new Column("Size", DbType.Int64, ColumnProperty.NotNull),
@ -107,7 +107,7 @@ namespace NzbDrone.Core.Datastore.Migrations
Database.AddTable("RootDirs", new[] Database.AddTable("RootDirs", new[]
{ {
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity), new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
new Column("Path", DbType.String, ColumnProperty.NotNull) new Column("Path", DbType.String, 4000, ColumnProperty.NotNull)
}); });
Database.AddTable("ExternalNotificationSettings", new[] Database.AddTable("ExternalNotificationSettings", new[]
@ -118,7 +118,7 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("Name", DbType.String, ColumnProperty.NotNull) new Column("Name", DbType.String, ColumnProperty.NotNull)
}); });
Database.AddTable("JobSettings", new[] Database.AddTable("JobDefinitions", new[]
{ {
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity), new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull), new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),
@ -140,16 +140,16 @@ namespace NzbDrone.Core.Datastore.Migrations
Database.AddTable("Logs", new[] Database.AddTable("Logs", new[]
{ {
new Column("LogId", DbType.Int64, ColumnProperty.PrimaryKeyWithIdentity), new Column("LogId", DbType.Int64, ColumnProperty.PrimaryKeyWithIdentity),
new Column("Message", DbType.String, ColumnProperty.NotNull), new Column("Message", DbType.String,4000, ColumnProperty.NotNull),
new Column("Time", DbType.DateTime, ColumnProperty.NotNull), new Column("Time", DbType.DateTime, ColumnProperty.NotNull),
new Column("Logger", DbType.String, ColumnProperty.NotNull), new Column("Logger", DbType.String, ColumnProperty.NotNull),
new Column("Method", DbType.String, ColumnProperty.NotNull), new Column("Method", DbType.String, ColumnProperty.NotNull),
new Column("Exception", DbType.String, ColumnProperty.Null), new Column("Exception", DbType.String,4000, ColumnProperty.Null),
new Column("ExceptionType", DbType.String, ColumnProperty.Null), new Column("ExceptionType", DbType.String, ColumnProperty.Null),
new Column("Level", DbType.String, ColumnProperty.NotNull) new Column("Level", DbType.String, ColumnProperty.NotNull)
}); });
Database.AddTable("IndexerSettings", new[] Database.AddTable("IndexerDefinitions", new[]
{ {
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity), new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull), new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),

View File

@ -176,8 +176,7 @@
<Compile Include="Datastore\MigrationLogger.cs" /> <Compile Include="Datastore\MigrationLogger.cs" />
<Compile Include="Datastore\MigrationsHelper.cs" /> <Compile Include="Datastore\MigrationsHelper.cs" />
<Compile Include="Datastore\CustomeMapper.cs" /> <Compile Include="Datastore\CustomeMapper.cs" />
<Compile Include="Datastore\Migrations\Migration20110705.cs" /> <Compile Include="Datastore\Migrations\Migration20110707.cs" />
<Compile Include="Datastore\Migrations\Migration20110622.cs" />
<Compile Include="Datastore\SqliteProvider.cs" /> <Compile Include="Datastore\SqliteProvider.cs" />
<Compile Include="Fluent.cs" /> <Compile Include="Fluent.cs" />
<Compile Include="Helpers\EpisodeSortingHelper.cs" /> <Compile Include="Helpers\EpisodeSortingHelper.cs" />
@ -215,8 +214,8 @@
<Compile Include="Providers\Jobs\UpdateInfoJob.cs" /> <Compile Include="Providers\Jobs\UpdateInfoJob.cs" />
<Compile Include="Providers\SceneMappingProvider.cs" /> <Compile Include="Providers\SceneMappingProvider.cs" />
<Compile Include="Repository\ExternalNotificationSetting.cs" /> <Compile Include="Repository\ExternalNotificationSetting.cs" />
<Compile Include="Repository\JobSetting.cs" /> <Compile Include="Repository\JobDefinition.cs" />
<Compile Include="Repository\IndexerSetting.cs" /> <Compile Include="Repository\IndexerDefinition.cs" />
<Compile Include="Model\EpisodeParseResult.cs" /> <Compile Include="Model\EpisodeParseResult.cs" />
<Compile Include="Model\EpisodeRenameModel.cs" /> <Compile Include="Model\EpisodeRenameModel.cs" />
<Compile Include="Model\EpisodeSortingType.cs" /> <Compile Include="Model\EpisodeSortingType.cs" />

View File

@ -34,28 +34,28 @@ namespace NzbDrone.Core.Providers
return _indexers.Where(i => all.Exists(c => c.IndexProviderType == i.GetType().ToString() && c.Enable)).ToList(); return _indexers.Where(i => all.Exists(c => c.IndexProviderType == i.GetType().ToString() && c.Enable)).ToList();
} }
public virtual List<IndexerSetting> GetAllISettings() public virtual List<IndexerDefinition> GetAllISettings()
{ {
return _database.Fetch<IndexerSetting>(); return _database.Fetch<IndexerDefinition>();
} }
public virtual void SaveSettings(IndexerSetting settings) public virtual void SaveSettings(IndexerDefinition definitions)
{ {
if (settings.Id == 0) if (definitions.Id == 0)
{ {
Logger.Debug("Adding Indexer settings for {0}", settings.Name); Logger.Debug("Adding Indexer definitions for {0}", definitions.Name);
_database.Insert(settings); _database.Insert(definitions);
} }
else else
{ {
Logger.Debug("Updating Indexer settings for {0}", settings.Name); Logger.Debug("Updating Indexer definitions for {0}", definitions.Name);
_database.Update(settings); _database.Update(definitions);
} }
} }
public virtual IndexerSetting GetSettings(Type type) public virtual IndexerDefinition GetSettings(Type type)
{ {
return _database.Single<IndexerSetting>("WHERE IndexProviderType = @0", type.ToString()); return _database.Single<IndexerDefinition>("WHERE IndexProviderType = @0", type.ToString());
} }
public virtual void InitializeIndexers(IList<IndexerBase> indexers) public virtual void InitializeIndexers(IList<IndexerBase> indexers)
@ -71,7 +71,7 @@ namespace NzbDrone.Core.Providers
IndexerBase indexerLocal = feedProvider; IndexerBase indexerLocal = feedProvider;
if (!currentIndexers.Exists(c => c.IndexProviderType == indexerLocal.GetType().ToString())) if (!currentIndexers.Exists(c => c.IndexProviderType == indexerLocal.GetType().ToString()))
{ {
var settings = new IndexerSetting var settings = new IndexerDefinition
{ {
Enable = false, Enable = false,
IndexProviderType = indexerLocal.GetType().ToString(), IndexProviderType = indexerLocal.GetType().ToString(),

View File

@ -40,26 +40,26 @@ namespace NzbDrone.Core.Providers.Jobs
/// Returns a list of all registered jobs /// Returns a list of all registered jobs
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public virtual List<JobSetting> All() public virtual List<JobDefinition> All()
{ {
return _database.Fetch<JobSetting>().ToList(); return _database.Fetch<JobDefinition>().ToList();
} }
/// <summary> /// <summary>
/// Creates/Updates settings for a job /// Creates/Updates definitions for a job
/// </summary> /// </summary>
/// <param name="settings">Settings to be created/updated</param> /// <param name="definitions">Settings to be created/updated</param>
public virtual void SaveSettings(JobSetting settings) public virtual void SaveSettings(JobDefinition definitions)
{ {
if (settings.Id == 0) if (definitions.Id == 0)
{ {
Logger.Trace("Adding job settings for {0}", settings.Name); Logger.Trace("Adding job definitions for {0}", definitions.Name);
_database.Insert(settings); _database.Insert(definitions);
} }
else else
{ {
Logger.Trace("Updating job settings for {0}", settings.Name); Logger.Trace("Updating job definitions for {0}", definitions.Name);
_database.Update(settings); _database.Update(definitions);
} }
} }
@ -286,7 +286,7 @@ namespace NzbDrone.Core.Providers.Jobs
var timerProviderLocal = timer; var timerProviderLocal = timer;
if (!currentTimer.Exists(c => c.TypeName == timerProviderLocal.GetType().ToString())) if (!currentTimer.Exists(c => c.TypeName == timerProviderLocal.GetType().ToString()))
{ {
var settings = new JobSetting var settings = new JobDefinition
{ {
Enable = timerProviderLocal.DefaultInterval > 0, Enable = timerProviderLocal.DefaultInterval > 0,
TypeName = timer.GetType().ToString(), TypeName = timer.GetType().ToString(),

View File

@ -3,9 +3,9 @@ using PetaPoco;
namespace NzbDrone.Core.Repository namespace NzbDrone.Core.Repository
{ {
[TableName("IndexerSettings")] [TableName("IndexerDefinitions")]
[PrimaryKey("Id", autoIncrement = true)] [PrimaryKey("Id", autoIncrement = true)]
public class IndexerSetting public class IndexerDefinition
{ {
public int Id { get; set; } public int Id { get; set; }

View File

@ -3,9 +3,9 @@ using PetaPoco;
namespace NzbDrone.Core.Repository namespace NzbDrone.Core.Repository
{ {
[TableName("JobSettings")] [TableName("JobDefinitions")]
[PrimaryKey("Id", autoIncrement = true)] [PrimaryKey("Id", autoIncrement = true)]
public class JobSetting public class JobDefinition
{ {
public Int32 Id { get; set; } public Int32 Id { get; set; }

View File

@ -49,18 +49,13 @@ namespace NzbDrone.Web.Controllers
public ActionResult AddNew() public ActionResult AddNew()
{ {
var rootDirs = _rootFolderProvider.GetAll().Select(r => ViewData["RootDirs"] = _rootFolderProvider.GetAll().Select(c => c.Path).OrderBy(e => e).ToList();
new RootDirModel
{
Path = r.Path,
CleanPath = r.Path.Replace(Path.DirectorySeparatorChar, '|').Replace(Path.VolumeSeparatorChar, '^').Replace('\'', '`')
});
ViewData["RootDirs"] = rootDirs.ToList();
ViewData["DirSep"] = Path.DirectorySeparatorChar.ToString().Replace(Path.DirectorySeparatorChar, '|');
var defaultQuality = _configProvider.DefaultQualityProfile; var defaultQuality = _configProvider.DefaultQualityProfile;
var qualityProfiles = _qualityProvider.GetAllProfiles(); var qualityProfiles = _qualityProvider.GetAllProfiles();
ViewData["qualityList"] = qualityProfiles;
ViewData["quality"] = new SelectList( ViewData["quality"] = new SelectList(
qualityProfiles, qualityProfiles,
"QualityProfileId", "QualityProfileId",

View File

@ -1,22 +1,11 @@
@using NzbDrone.Web.Models @using System.Collections
@{ @using NzbDrone.Web.Models
Layout = null; @{ Layout = null; }
}
<div> <div>
<fieldset> @Html.Label("Root Directory")
<legend>Root Directory</legend> @Html.DropDownList("rootDirList", new SelectList((IList)ViewData["RootDirs"]))
@{int d = 0; @Html.Label("Quality")
@Html.DropDownList("qualityList", new SelectList((IList)ViewData["QualityList"], "QualityProfileId", "Name"))
foreach (var dir in ViewData["RootDirs"] as List<RootDirModel>)
{
<div>
@Html.RadioButton("selectedRootDir", dir.CleanPath, d == 0, new { @class = "dirList examplePart", id = "dirRadio_" + d })
@Html.Label(dir.Path)
@{ d++; }
</div>
}
}
</fieldset>
</div> </div>
<br /> <br />
<div> <div>

View File

@ -1,45 +1,40 @@
@model List<RootDir> @model List<RootDir>
@using NzbDrone.Core.Repository @using NzbDrone.Core.Repository
@section HeaderContent @section HeaderContent
{ {
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/yui/3.3.0/build/yui/yui-min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/yui/3.3.0/build/yui/yui-min.js"></script>
} }
@section TitleContent{ @section TitleContent{
Add Series Add Series
} }
@section MainContent{ @section MainContent{
@{ Html.Telerik().Window() <div id="addNewWindow" class="dialog">
.Name("Window") @{ Html.RenderAction("AddNew", "AddSeries"); }
.Title("Add New Series")
.Modal(true)
.Buttons(b => b.Close())
.Width(500)
.Height(200)
.Visible(false)
.Draggable(true)
.Resizable(resizing => resizing.Enabled(false))
.LoadContentFrom("AddNew", "AddSeries")
.Render();
}
<div style="padding-bottom: 10px; padding-top: 15px;">
<button onclick="openAddNewSeries(); return false;" class="listButton" style="margin-left: 5px">
Add New</button>
@Html.Telerik().DropDownList().Name("masterDropbox").BindTo((SelectList)ViewData["qualities"]).HtmlAttributes(
new { style = "width: 100px; margin-left:224px;" }).ClientEvents(events => events.OnChange("masterChanged"))
</div> </div>
@{Html.RenderAction("RootDir");} @{Html.RenderAction("RootDir");}
<div id="existingSeries"> <div id="existingSeries">
<div style="padding-bottom: 10px; padding-top: 15px;">
<button onclick="openAddNewSeries(); return false;" class="listButton" style="margin-left: 5px">
Add New</button>
@Html.Telerik().DropDownList().Name("masterDropbox").BindTo((SelectList)ViewData["qualities"]).HtmlAttributes(
new { style = "width: 100px; margin-left:224px;" }).ClientEvents(events => events.OnChange("masterChanged"))
</div>
@{ Html.RenderAction("AddExisting", "AddSeries"); } @{ Html.RenderAction("AddExisting", "AddSeries"); }
</div> </div>
} }
@section Scripts @section Scripts
{ {
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () {
$("#addNewWindow").dialog({
title: 'add new series',
height: '500',
width: '700',
modal: true
});
});
function openAddNewSeries() { function openAddNewSeries() {
var window = $('#Window').data('tWindow'); var window = $('#Window').data('tWindow');
window.center().open(); window.center().open();

View File

@ -1,4 +1,4 @@
@model IEnumerable<NzbDrone.Core.Repository.IndexerSetting> @model IEnumerable<NzbDrone.Core.Repository.IndexerDefinition>
@section TitleContent{ @section TitleContent{
Indexers Indexers
} }

View File

@ -1,4 +1,4 @@
@model IEnumerable<NzbDrone.Core.Repository.JobSetting> @model IEnumerable<NzbDrone.Core.Repository.JobDefinition>
@section TitleContent{ @section TitleContent{
Jobs Jobs
} }