diff --git a/app/Http/Controllers/Api/V1/TracksController.php b/app/Http/Controllers/Api/V1/TracksController.php index 16fe5af0..773b13dc 100644 --- a/app/Http/Controllers/Api/V1/TracksController.php +++ b/app/Http/Controllers/Api/V1/TracksController.php @@ -100,7 +100,11 @@ class TracksController extends \ApiControllerBase 'small' => $track->getCoverUrl(Image::SMALL), 'normal' => $track->getCoverUrl(Image::NORMAL) ], - 'comments' => $comments + 'comments' => $comments, + + // As of 2015-10-28, this should be expected to produce either + // "direct_upload" or "mlpma" for all tracks. + 'source' => $track->source ], 200); } } diff --git a/database/migrations/2015_10_26_231224_AddTrackSourceColumn.php b/database/migrations/2015_10_26_231224_AddTrackSourceColumn.php new file mode 100644 index 00000000..c9631c15 --- /dev/null +++ b/database/migrations/2015_10_26_231224_AddTrackSourceColumn.php @@ -0,0 +1,39 @@ +string('source', 40)->default('direct_upload'); + }); + + // Mark MLPMA tracks retroactively + // --> The default value in the database, set above, will + // be used automatically for all non-MLPMA tracks. + $tracks = DB::table('tracks') + ->join('mlpma_tracks', 'mlpma_tracks.track_id', '=', 'tracks.id'); + + $tracks->whereNotNull('mlpma_tracks.id')->update(['source' => 'mlpma']); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('tracks', function(Blueprint $table){ + $table->dropColumn('source'); + }); + } +}