2019-05-05 03:50:00 +00:00
|
|
|
using System.Data;
|
|
|
|
using FluentMigrator;
|
|
|
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Datastore.Migration
|
|
|
|
{
|
2019-10-05 18:34:34 +00:00
|
|
|
[Migration(33)]
|
2019-05-05 03:50:00 +00:00
|
|
|
public class download_propers_config : NzbDroneMigrationBase
|
|
|
|
{
|
|
|
|
protected override void MainDbUpgrade()
|
|
|
|
{
|
|
|
|
Execute.WithConnection(SetConfigValue);
|
2022-01-26 00:08:27 +00:00
|
|
|
Execute.Sql("DELETE FROM \"Config\" WHERE \"Key\" = 'autodownloadpropers'");
|
2019-05-05 03:50:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void SetConfigValue(IDbConnection conn, IDbTransaction tran)
|
|
|
|
{
|
|
|
|
using (var cmd = conn.CreateCommand())
|
|
|
|
{
|
|
|
|
cmd.Transaction = tran;
|
2022-01-26 00:08:27 +00:00
|
|
|
cmd.CommandText = "SELECT \"Value\" FROM \"Config\" WHERE \"Key\" = 'autodownloadpropers'";
|
2019-05-05 03:50:00 +00:00
|
|
|
|
|
|
|
using (var reader = cmd.ExecuteReader())
|
|
|
|
{
|
|
|
|
while (reader.Read())
|
|
|
|
{
|
|
|
|
var value = reader.GetString(0);
|
|
|
|
var newValue = bool.Parse(value) ? "PreferAndUpgrade" : "DoNotUpgrade";
|
|
|
|
|
|
|
|
using (var updateCmd = conn.CreateCommand())
|
|
|
|
{
|
|
|
|
updateCmd.Transaction = tran;
|
2022-01-26 00:08:27 +00:00
|
|
|
updateCmd.CommandText = "INSERT INTO \"Config\" (\"key\", \"value\") VALUES ('downloadpropersandrepacks', ?)";
|
2019-05-05 03:50:00 +00:00
|
|
|
updateCmd.AddParameter(newValue);
|
|
|
|
|
|
|
|
updateCmd.ExecuteNonQuery();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|