Browse Source

fix: Migration 18 didnt migrate playlist and queue songs

Owen Diffey 3 years ago
parent
commit
97b2d50b88
2 changed files with 34 additions and 34 deletions
  1. 2 2
      backend/logic/actions/stations.js
  2. 32 32
      backend/logic/migration/migrations/migration18.js

+ 2 - 2
backend/logic/actions/stations.js

@@ -2971,7 +2971,7 @@ export default {
 					)
 						.then(response => {
 							const { song } = response;
-							const { _id, title, skipDuration, artists, thumbnail, duration, status } = song;
+							const { _id, title, skipDuration, artists, thumbnail, duration, verified } = song;
 							next(
 								null,
 								{
@@ -2982,7 +2982,7 @@ export default {
 									artists,
 									thumbnail,
 									duration,
-									status
+									verified
 								},
 								station
 							);

+ 32 - 32
backend/logic/migration/migrations/migration18.js

@@ -77,9 +77,37 @@ export default async function migrate(MigrationModule) {
 					);
 				},
 
+				next => {
+					playlistModel.updateMany({ documentVersion: 5 }, { $set: { documentVersion: 6 } }, (err, res) => {
+						if (err) next(err);
+						else {
+							this.log(
+								"INFO",
+								`Migration 18 (playlist). Matched: ${res.matchedCount}, modified: ${res.modifiedCount}, ok: ${res.ok}.`
+							);
+
+							next();
+						}
+					});
+				},
+
+				next => {
+					stationModel.updateMany({ documentVersion: 6 }, { $set: { documentVersion: 7 } }, (err, res) => {
+						if (err) next(err);
+						else {
+							this.log(
+								"INFO",
+								`Migration 18 (station). Matched: ${res.matchedCount}, modified: ${res.modifiedCount}, ok: ${res.ok}.`
+							);
+
+							next();
+						}
+					});
+				},
+
 				next => {
 					this.log("INFO", `Migration 18. Updating playlist songs and queue songs.`);
-					songModel.find({ documentVersion: 6 }, (err, songs) => {
+					songModel.find({ documentVersion: 7 }, (err, songs) => {
 						if (err) next(err);
 						else {
 							async.eachLimit(
@@ -110,7 +138,7 @@ export default async function migrate(MigrationModule) {
 										[
 											next => {
 												playlistModel.updateMany(
-													{ "songs._id": song._id, documentVersion: 5 },
+													{ "songs._id": song._id, documentVersion: 6 },
 													{ $set: { "songs.$": trimmedSong } },
 													next
 												);
@@ -118,7 +146,7 @@ export default async function migrate(MigrationModule) {
 
 											(res, next) => {
 												stationModel.updateMany(
-													{ "queue._id": song._id, documentVersion: 6 },
+													{ "queue._id": song._id, documentVersion: 7 },
 													{ $set: { "queue.$": trimmedSong } },
 													next
 												);
@@ -126,7 +154,7 @@ export default async function migrate(MigrationModule) {
 
 											(res, next) => {
 												stationModel.updateMany(
-													{ "currentSong._id": song._id, documentVersion: 6 },
+													{ "currentSong._id": song._id, documentVersion: 7 },
 													{ $set: { currentSong: null } },
 													next
 												);
@@ -143,34 +171,6 @@ export default async function migrate(MigrationModule) {
 							);
 						}
 					});
-				},
-
-				next => {
-					playlistModel.updateMany({ documentVersion: 5 }, { $set: { documentVersion: 6 } }, (err, res) => {
-						if (err) next(err);
-						else {
-							this.log(
-								"INFO",
-								`Migration 18 (playlist). Matched: ${res.matchedCount}, modified: ${res.modifiedCount}, ok: ${res.ok}.`
-							);
-
-							next();
-						}
-					});
-				},
-
-				next => {
-					stationModel.updateMany({ documentVersion: 6 }, { $set: { documentVersion: 7 } }, (err, res) => {
-						if (err) next(err);
-						else {
-							this.log(
-								"INFO",
-								`Migration 18 (station). Matched: ${res.matchedCount}, modified: ${res.modifiedCount}, ok: ${res.ok}.`
-							);
-
-							next();
-						}
-					});
 				}
 			],
 			err => {