Add PostgreSQL specific query for cleaning multiple monitored editions

Fixes #2995
pull/2997/head
Bogdan 1 year ago
parent d248747635
commit b9d53ed732

@ -16,15 +16,30 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
{
using var mapper = _database.OpenConnection();
mapper.Execute(@"UPDATE ""Editions""
SET ""Monitored"" = 0
WHERE ""Id"" IN (
SELECT MIN(""Id"")
FROM ""Editions""
WHERE ""Monitored"" = 1
GROUP BY ""BookId""
HAVING COUNT(""BookId"") > 1
)");
if (_database.DatabaseType == DatabaseType.PostgreSQL)
{
mapper.Execute(@"UPDATE ""Editions""
SET ""Monitored"" = true
WHERE ""Id"" IN (
SELECT MIN(""Id"")
FROM ""Editions""
WHERE ""Monitored"" = true
GROUP BY ""BookId""
HAVING COUNT(""BookId"") > 1
)");
}
else
{
mapper.Execute(@"UPDATE ""Editions""
SET ""Monitored"" = 0
WHERE ""Id"" IN (
SELECT MIN(""Id"")
FROM ""Editions""
WHERE ""Monitored"" = 1
GROUP BY ""BookId""
HAVING COUNT(""BookId"") > 1
)");
}
}
}
}

Loading…
Cancel
Save