42 lines
988 B
PHP
42 lines
988 B
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
class AddParentAlbumColumn extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
Schema::table('albums', function (Blueprint $table)
|
|
{
|
|
$table->unsignedInteger('parent_album_id')->nullable();
|
|
$table->string('url_path')->nullable();
|
|
|
|
$table->foreign('parent_album_id')
|
|
->references('id')->on('albums')
|
|
->onDelete('set null');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
Schema::table('albums', function (Blueprint $table)
|
|
{
|
|
$table->dropForeign('albums_parent_album_id_foreign');
|
|
$table->dropColumn('parent_album_id');
|
|
$table->dropColumn('url_path');
|
|
});
|
|
}
|
|
}
|