|
|
|
@ -31,7 +31,16 @@ namespace NzbDrone.Core.Datastore.Migration
|
|
|
|
|
WHERE ""Artists"".""Path"" IS NULL)");
|
|
|
|
|
|
|
|
|
|
// Remove anything linked to unmonitored or unidentified releases. This should ensure uniqueness of track files.
|
|
|
|
|
Execute.Sql(@"DELETE FROM ""TrackFiles""
|
|
|
|
|
IfDatabase("sqlite").Execute.Sql(@"DELETE FROM ""TrackFiles""
|
|
|
|
|
WHERE ""Id"" IN (
|
|
|
|
|
SELECT ""TrackFiles"".""Id"" FROM ""TrackFiles""
|
|
|
|
|
LEFT JOIN ""Tracks"" ON ""TrackFiles"".""Id"" = ""Tracks"".""TrackFileId""
|
|
|
|
|
LEFT JOIN ""AlbumReleases"" ON ""Tracks"".""AlbumReleaseId"" = ""AlbumReleases"".""Id""
|
|
|
|
|
WHERE ""AlbumReleases"".""Monitored"" = 0
|
|
|
|
|
OR ""AlbumReleases"".""Monitored"" IS NULL)");
|
|
|
|
|
|
|
|
|
|
// Remove anything linked to unmonitored or unidentified releases. This should ensure uniqueness of track files.
|
|
|
|
|
IfDatabase("postgres").Execute.Sql(@"DELETE FROM ""TrackFiles""
|
|
|
|
|
WHERE ""Id"" IN (
|
|
|
|
|
SELECT ""TrackFiles"".""Id"" FROM ""TrackFiles""
|
|
|
|
|
LEFT JOIN ""Tracks"" ON ""TrackFiles"".""Id"" = ""Tracks"".""TrackFileId""
|
|
|
|
@ -40,8 +49,8 @@ namespace NzbDrone.Core.Datastore.Migration
|
|
|
|
|
OR ""AlbumReleases"".""Monitored"" IS NULL)");
|
|
|
|
|
|
|
|
|
|
// Populate the full paths
|
|
|
|
|
Execute.Sql(@"UPDATE ""TrackFiles""
|
|
|
|
|
SET ""Path"" = (SELECT ""Artists"".""Path"" || '" + System.IO.Path.DirectorySeparatorChar + @"' || ""TrackFiles"".""RelativePath""
|
|
|
|
|
Execute.Sql($@"UPDATE ""TrackFiles""
|
|
|
|
|
SET ""Path"" = (SELECT ""Artists"".""Path"" || '{System.IO.Path.DirectorySeparatorChar}' || ""TrackFiles"".""RelativePath""
|
|
|
|
|
FROM ""Artists""
|
|
|
|
|
JOIN ""Albums"" ON ""Albums"".""ArtistMetadataId"" = ""Artists"".""ArtistMetadataId""
|
|
|
|
|
WHERE ""TrackFiles"".""AlbumId"" = ""Albums"".""Id"")");
|
|
|
|
|