1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-01-30 11:21:26 +00:00

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 @@ public void parse_feed_xml(string fileName, int warns)
.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 @@ public void newzbin_rss_fetch()
{
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 @@ public void custome_parser_partial_success(string title, int season, int episode
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 @@ public void custome_parser_full_parse(string title)
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 @@ public void downloadFeed()
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);

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 @@
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 @@ public override void Up()
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 @@ public override void Up()
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 @@ public override void Up()
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 @@ public override void Up()
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 @@ public override void Up()
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 @@ public override void Up()
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),

View file

@ -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" />

View file

@ -34,28 +34,28 @@ public virtual IList<IndexerBase> GetEnabledIndexers()
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 @@ public virtual void InitializeIndexers(IList<IndexerBase> indexers)
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(),

View file

@ -40,26 +40,26 @@ public JobProvider() { }
/// 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 @@ public virtual void Initialize()
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(),

View file

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

View file

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

View file

@ -49,18 +49,13 @@ public JsonResult ScanNewSeries()
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",

View file

@ -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>

View file

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

View file

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

View file

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