1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

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

View File

@ -74,13 +74,12 @@ private void ConvertQualityModel(IDbConnection conn, IDbTransaction tran, string
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 @@ private void ConvertQualityModel(IDbConnection conn, IDbTransaction tran, string
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();
}