Pony.fm/database/migrations/2013_07_28_060804_create_albums.php

48 lines
1.5 KiB
PHP
Raw Normal View History

2015-08-30 14:29:12 +02:00
<?php
use Illuminate\Database\Migrations\Migration;
2015-08-31 14:35:47 +02:00
class CreateAlbums extends Migration
{
public function up()
{
Schema::create('albums', function ($table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->string('title')->index();
$table->string('slug')->index();
$table->text('description');
$table->integer('cover_id')->unsigned()->nullable();
$table->integer('track_count')->unsigned();
$table->integer('view_count')->unsigned();
$table->integer('download_count')->unsigned();
$table->integer('favourite_count')->unsigned();
$table->integer('comment_count')->unsigned();
$table->timestamps();
$table->timestamp('deleted_at')->nullable()->index();
$table->foreign('cover_id')->references('id')->on('images');
$table->foreign('user_id')->references('id')->on('users');
});
Schema::table('tracks', function ($table) {
$table->integer('album_id')->unsigned()->nullable();
$table->integer('track_number')->unsigned()->nullable();
$table->foreign('album_id')->references('id')->on('albums');
});
}
public function down()
{
Schema::table('tracks', function ($table) {
$table->dropForeign('tracks_album_id_foreign');
$table->dropColumn('album_id');
$table->dropColumn('track_number');
});
Schema::drop('albums');
}
2015-08-30 14:29:12 +02:00
}