Fixed: Migration 23 doesn't set Track.ArtistMetadataId (#756)

pull/6/head
Qstick 6 years ago committed by GitHub
parent 59cc5584c6
commit 1212578c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -95,8 +95,12 @@ namespace NzbDrone.Core.Test.Datastore.Migration
"JOIN AlbumReleases ON Tracks.AlbumReleaseId = AlbumReleases.Id " + "JOIN AlbumReleases ON Tracks.AlbumReleaseId = AlbumReleases.Id " +
"JOIN Albums ON AlbumReleases.AlbumId = Albums.Id " + "JOIN Albums ON AlbumReleases.AlbumId = Albums.Id " +
"WHERE Albums.Id = " + albumId).ToList(); "WHERE Albums.Id = " + albumId).ToList();
var album = db.Query<Album>("SELECT * FROM Albums WHERE Albums.Id = " + albumId).ToList().Single();
tracks.Count.Should().Be(expectedCount); tracks.Count.Should().Be(expectedCount);
tracks.First().AlbumReleaseId.Should().Be(albumReleaseId); tracks.First().AlbumReleaseId.Should().Be(albumReleaseId);
tracks.All(t => t.ArtistMetadataId == album.ArtistMetadataId).Should().BeTrue();
} }
[Test] [Test]

@ -88,6 +88,13 @@ namespace NzbDrone.Core.Datastore.Migration
JOIN Albums ON AlbumReleases.AlbumId = Albums.Id JOIN Albums ON AlbumReleases.AlbumId = Albums.Id
WHERE Albums.Id = Tracks.AlbumId)"); WHERE Albums.Id = Tracks.AlbumId)");
// Set metadata ID
Execute.Sql(@"UPDATE Tracks
SET ArtistMetadataId = (SELECT ArtistMetadata.Id
FROM ArtistMetadata
JOIN Albums ON ArtistMetadata.Id = Albums.ArtistMetadataId
WHERE Tracks.AlbumId = Albums.Id)");
// CLEAR OUT OLD COLUMNS // CLEAR OUT OLD COLUMNS
// Remove the columns in Artists now in ArtistMetadata // Remove the columns in Artists now in ArtistMetadata

Loading…
Cancel
Save