mirror of https://github.com/lidarr/Lidarr
Migration to new quality takes seconds not minutes now
This commit is contained in:
parent
c9a77e99a0
commit
03ba8d071e
|
@ -74,13 +74,12 @@ namespace NzbDrone.Core.Datastore.Migration
|
||||||
using (IDbCommand qualityModelCmd = conn.CreateCommand())
|
using (IDbCommand qualityModelCmd = conn.CreateCommand())
|
||||||
{
|
{
|
||||||
qualityModelCmd.Transaction = tran;
|
qualityModelCmd.Transaction = tran;
|
||||||
qualityModelCmd.CommandText = @"SELECT Id, Quality FROM " + tableName;
|
qualityModelCmd.CommandText = @"SELECT Distinct Quality FROM " + tableName;
|
||||||
using (IDataReader qualityModelReader = qualityModelCmd.ExecuteReader())
|
using (IDataReader qualityModelReader = qualityModelCmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
while (qualityModelReader.Read())
|
while (qualityModelReader.Read())
|
||||||
{
|
{
|
||||||
var id = qualityModelReader.GetInt32(0);
|
var qualityJson = qualityModelReader.GetString(0);
|
||||||
var qualityJson = qualityModelReader.GetString(1);
|
|
||||||
|
|
||||||
QualityModel quality;
|
QualityModel quality;
|
||||||
|
|
||||||
|
@ -94,9 +93,9 @@ namespace NzbDrone.Core.Datastore.Migration
|
||||||
using (IDbCommand updateCmd = conn.CreateCommand())
|
using (IDbCommand updateCmd = conn.CreateCommand())
|
||||||
{
|
{
|
||||||
updateCmd.Transaction = tran;
|
updateCmd.Transaction = tran;
|
||||||
updateCmd.CommandText = "UPDATE " + tableName + " SET Quality = ? WHERE Id = ?";
|
updateCmd.CommandText = "UPDATE " + tableName + " SET Quality = ? WHERE Quality = ?";
|
||||||
updateCmd.AddParameter(qualityNewJson);
|
updateCmd.AddParameter(qualityNewJson);
|
||||||
updateCmd.AddParameter(id);
|
updateCmd.AddParameter(qualityJson);
|
||||||
|
|
||||||
updateCmd.ExecuteNonQuery();
|
updateCmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue