Fixed broken migration 036 for people upgrading from very old DBs

This commit is contained in:
Mark McDowall 2014-10-30 22:26:48 -07:00
parent aadd9243a4
commit 86aba08289
1 changed files with 19 additions and 4 deletions

View File

@ -83,14 +83,18 @@ namespace NzbDrone.Core.Datastore.Migration
{ {
var qualityJson = qualityModelReader.GetString(0); var qualityJson = qualityModelReader.GetString(0);
QualityModel036 quality; SourceQualityModel036 sourceQuality;
if (!Json.TryDeserialize<QualityModel036>(qualityJson, out quality)) if (!Json.TryDeserialize<SourceQualityModel036>(qualityJson, out sourceQuality))
{ {
continue; continue;
} }
var qualityNewJson = qualityModelConverter.ToDB(quality); var qualityNewJson = qualityModelConverter.ToDB(new DestinationQualityModel036
{
Quality = sourceQuality.Quality.Id,
Proper = sourceQuality.Proper
});
using (IDbCommand updateCmd = conn.CreateCommand()) using (IDbCommand updateCmd = conn.CreateCommand())
{ {
@ -106,10 +110,21 @@ namespace NzbDrone.Core.Datastore.Migration
} }
} }
private class QualityModel036 private class DestinationQualityModel036
{ {
public Int32 Quality { get; set; } public Int32 Quality { get; set; }
public Boolean Proper { get; set; } public Boolean Proper { get; set; }
} }
private class SourceQualityModel036
{
public SourceQuality036 Quality { get; set; }
public Boolean Proper { get; set; }
}
private class SourceQuality036
{
public Int32 Id { get; set; }
}
} }
} }