Browse Source

Fixed some more issues with migration2

Kristian Vos 4 years ago
parent
commit
f721a4cc07

+ 1 - 1
backend/logic/db/schemas/station.js

@@ -49,5 +49,5 @@ export default {
 	theme: { type: String, enum: ["blue", "purple", "teal", "orange"], default: "blue" },
 	includedPlaylists: [{ type: String }],
 	excludedPlaylists: [{ type: String }],
-	documentVersion: { type: Number, default: 1, required: true }
+	documentVersion: { type: Number, default: 2, required: true }
 };

+ 5 - 2
backend/logic/migration/migrations/migration2.js

@@ -20,7 +20,10 @@ export default async function migrate(MigrationModule) {
 					stationModel.find({ documentVersion: 1 }, (err, stations) => {
 						this.log("INFO", `Migration 2. Found ${stations.length} stations with document version 1.`);
 
-						next(null, stations);
+						next(
+							null,
+							stations.map(station => station._doc)
+						);
 					});
 				},
 
@@ -41,7 +44,6 @@ export default async function migrate(MigrationModule) {
 									type: "station",
 									documentVersion: 1
 								},
-
 								(err, playlist2) => {
 									if (err) next(err);
 									else {
@@ -53,6 +55,7 @@ export default async function migrate(MigrationModule) {
 													playlist2: playlist2._id,
 													includedPlaylists: [],
 													excludedPlaylists: [],
+													playlist: station.type === "official" ? [] : station.playlist,
 													documentVersion: 2
 												}
 											},