database/migrations/2019_05_02_141056_create_albums_table.php
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
/**
* Class CreateAlbumsTable.
*/
class CreateAlbumsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create(
'albums',
function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->text('description')->nullable();
$table->date('release_date')->nullable();
$table->string('image')->nullable();
$table->unsignedBigInteger('genre_id')->nullable();
$table->unsignedBigInteger('user_id');
$table->timestamps();
$table->foreign('genre_id')
->references('id')
->on('genres');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('albums');
}
}