mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
Closes #6: Implemented a "source" attribute for tracks.
This commit is contained in:
parent
96b18643a1
commit
88a787cde8
2 changed files with 44 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddTrackSourceColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('tracks', function(Blueprint $table){
|
||||
$table->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');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue