some db/migration cleanup

pull/7/merge
kay.one 14 years ago
parent 8424dd6ede
commit 15aedfc847

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

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

@ -5,8 +5,8 @@ using Migrator.Framework;
namespace NzbDrone.Core.Datastore.Migrations
{
[Migration(20110622)]
public class Migration20110622 : Migration
[Migration(20110707)]
public class Migration20110707 : Migration
{
public override void Up()
{
@ -16,11 +16,11 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("Title", DbType.String, ColumnProperty.Null),
new Column("CleanTitle", 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("AirTimes", 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("QualityProfileId", DbType.Int32, 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("SeasonNumber", DbType.Int32, ColumnProperty.NotNull),
new Column("EpisodeNumber", DbType.Int32, ColumnProperty.NotNull),
new Column("Title", DbType.String, ColumnProperty.Null),
new Column("Overview", DbType.String, ColumnProperty.Null),
new Column("Title", DbType.String,100, ColumnProperty.Null),
new Column("Overview", DbType.String,4000, ColumnProperty.Null),
new Column("Ignored", DbType.Boolean, ColumnProperty.NotNull),
new Column("EpisodeFileId", DbType.Int32, ColumnProperty.Null),
new Column("AirDate", DbType.DateTime, ColumnProperty.Null),
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("EpisodeFileId", DbType.Int32,
ColumnProperty.PrimaryKeyWithIdentity),
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("Proper", DbType.Int32, ColumnProperty.NotNull),
new Column("Size", DbType.Int64, ColumnProperty.NotNull),
@ -107,7 +107,7 @@ namespace NzbDrone.Core.Datastore.Migrations
Database.AddTable("RootDirs", new[]
{
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[]
@ -118,7 +118,7 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("Name", DbType.String, ColumnProperty.NotNull)
});
Database.AddTable("JobSettings", new[]
Database.AddTable("JobDefinitions", new[]
{
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),
@ -140,16 +140,16 @@ namespace NzbDrone.Core.Datastore.Migrations
Database.AddTable("Logs", new[]
{
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("Logger", 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("Level", DbType.String, ColumnProperty.NotNull)
});
Database.AddTable("IndexerSettings", new[]
Database.AddTable("IndexerDefinitions", new[]
{
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),

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

@ -34,28 +34,28 @@ namespace NzbDrone.Core.Providers
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);
_database.Insert(settings);
Logger.Debug("Adding Indexer definitions for {0}", definitions.Name);
_database.Insert(definitions);
}
else
{
Logger.Debug("Updating Indexer settings for {0}", settings.Name);
_database.Update(settings);
Logger.Debug("Updating Indexer definitions for {0}", definitions.Name);
_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)
@ -71,7 +71,7 @@ namespace NzbDrone.Core.Providers
IndexerBase indexerLocal = feedProvider;
if (!currentIndexers.Exists(c => c.IndexProviderType == indexerLocal.GetType().ToString()))
{
var settings = new IndexerSetting
var settings = new IndexerDefinition
{
Enable = false,
IndexProviderType = indexerLocal.GetType().ToString(),

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

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

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

@ -49,18 +49,13 @@ namespace NzbDrone.Web.Controllers
public ActionResult AddNew()
{
var rootDirs = _rootFolderProvider.GetAll().Select(r =>
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, '|');
ViewData["RootDirs"] = _rootFolderProvider.GetAll().Select(c => c.Path).OrderBy(e => e).ToList();
var defaultQuality = _configProvider.DefaultQualityProfile;
var qualityProfiles = _qualityProvider.GetAllProfiles();
ViewData["qualityList"] = qualityProfiles;
ViewData["quality"] = new SelectList(
qualityProfiles,
"QualityProfileId",

@ -1,22 +1,11 @@
@using NzbDrone.Web.Models
@{
Layout = null;
}
@using System.Collections
@using NzbDrone.Web.Models
@{ Layout = null; }
<div>
<fieldset>
<legend>Root Directory</legend>
@{int d = 0;
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>
@Html.Label("Root Directory")
@Html.DropDownList("rootDirList", new SelectList((IList)ViewData["RootDirs"]))
@Html.Label("Quality")
@Html.DropDownList("qualityList", new SelectList((IList)ViewData["QualityList"], "QualityProfileId", "Name"))
</div>
<br />
<div>

@ -1,45 +1,40 @@
@model List<RootDir>
@using NzbDrone.Core.Repository
@section HeaderContent
{
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/yui/3.3.0/build/yui/yui-min.js"></script>
}
@section TitleContent{
Add Series
}
@section MainContent{
@{ Html.Telerik().Window()
.Name("Window")
.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 id="addNewWindow" class="dialog">
@{ Html.RenderAction("AddNew", "AddSeries"); }
</div>
@{Html.RenderAction("RootDir");}
<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"); }
</div>
}
@section Scripts
{
<script type="text/javascript">
$(document).ready(function () {
$("#addNewWindow").dialog({
title: 'add new series',
height: '500',
width: '700',
modal: true
});
});
function openAddNewSeries() {
var window = $('#Window').data('tWindow');
window.center().open();

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

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

Loading…
Cancel
Save