You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
using System.Data;
|
|
|
|
using FluentMigrator;
|
|
|
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Datastore.Migration
|
|
|
|
{
|
|
|
|
[Migration(183)]
|
|
|
|
public class download_propers_config : NzbDroneMigrationBase
|
|
|
|
{
|
|
|
|
protected override void MainDbUpgrade()
|
|
|
|
{
|
|
|
|
Execute.WithConnection(SetMetadataFileExtension);
|
|
|
|
Execute.Sql("DELETE FROM \"Config\" WHERE \"Key\" = 'autodownloadpropers'");
|
|
|
|
Delete.Column("PreferredTags").FromTable("Profiles");
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SetMetadataFileExtension(IDbConnection conn, IDbTransaction tran)
|
|
|
|
{
|
|
|
|
using (var cmd = conn.CreateCommand())
|
|
|
|
{
|
|
|
|
cmd.Transaction = tran;
|
|
|
|
cmd.CommandText = "SELECT \"Value\" FROM \"Config\" WHERE \"Key\" = 'autodownloadpropers'";
|
|
|
|
|
|
|
|
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;
|
|
|
|
updateCmd.CommandText = "INSERT INTO \"Config\" (\"key\", \"value\") VALUES ('downloadpropersandrepacks', ?)";
|
|
|
|
updateCmd.AddParameter(newValue);
|
|
|
|
|
|
|
|
updateCmd.ExecuteNonQuery();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|