mirror of
https://github.com/Readarr/Readarr
synced 2026-04-19 11:20:58 +02:00
Add PostgreSQL specific query for cleaning multiple monitored editions
Fixes #2995
This commit is contained in:
parent
d248747635
commit
b9d53ed732
1 changed files with 24 additions and 9 deletions
|
|
@ -16,15 +16,30 @@ public void Clean()
|
|||
{
|
||||
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…
Reference in a new issue