Migration to new quality takes seconds not minutes now

This commit is contained in:
markus101 2014-02-04 19:17:42 -08:00
parent c9a77e99a0
commit 03ba8d071e
1 changed files with 4 additions and 5 deletions

View File

@ -74,13 +74,12 @@ namespace NzbDrone.Core.Datastore.Migration
using (IDbCommand qualityModelCmd = conn.CreateCommand())
{
qualityModelCmd.Transaction = tran;
qualityModelCmd.CommandText = @"SELECT Id, Quality FROM " + tableName;
qualityModelCmd.CommandText = @"SELECT Distinct Quality FROM " + tableName;
using (IDataReader qualityModelReader = qualityModelCmd.ExecuteReader())
{
while (qualityModelReader.Read())
{
var id = qualityModelReader.GetInt32(0);
var qualityJson = qualityModelReader.GetString(1);
var qualityJson = qualityModelReader.GetString(0);
QualityModel quality;
@ -94,9 +93,9 @@ namespace NzbDrone.Core.Datastore.Migration
using (IDbCommand updateCmd = conn.CreateCommand())
{
updateCmd.Transaction = tran;
updateCmd.CommandText = "UPDATE " + tableName + " SET Quality = ? WHERE Id = ?";
updateCmd.CommandText = "UPDATE " + tableName + " SET Quality = ? WHERE Quality = ?";
updateCmd.AddParameter(qualityNewJson);
updateCmd.AddParameter(id);
updateCmd.AddParameter(qualityJson);
updateCmd.ExecuteNonQuery();
}