2020-09-05 06:18:42 +00:00
|
|
|
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);
|
2022-03-28 20:45:52 +00:00
|
|
|
Execute.Sql("DELETE FROM \"Config\" WHERE \"Key\" = 'autodownloadpropers'");
|
2020-09-05 06:18:42 +00:00
|
|
|
Delete.Column("PreferredTags").FromTable("Profiles");
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SetMetadataFileExtension(IDbConnection conn, IDbTransaction tran)
|
|
|
|
{
|
|
|
|
using (var cmd = conn.CreateCommand())
|
|
|
|
{
|
|
|
|
cmd.Transaction = tran;
|
2022-03-28 20:45:52 +00:00
|
|
|
cmd.CommandText = "SELECT \"Value\" FROM \"Config\" WHERE \"Key\" = 'autodownloadpropers'";
|
2020-09-05 06:18:42 +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-03-28 20:45:52 +00:00
|
|
|
updateCmd.CommandText = "INSERT INTO \"Config\" (\"key\", \"value\") VALUES ('downloadpropersandrepacks', ?)";
|
2020-09-05 06:18:42 +00:00
|
|
|
updateCmd.AddParameter(newValue);
|
|
|
|
|
|
|
|
updateCmd.ExecuteNonQuery();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|