FEATURE #1523: add subpages for content

This commit is contained in:
Michal Kváček
2016-03-31 21:12:54 +02:00
parent acc7541ab9
commit e789b02a93
10 changed files with 192 additions and 24 deletions
@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddSubpages extends Migration
{
/**
* Run the migrations.
* @return void
*/
public function up()
{
Schema::table('contents', function (Blueprint $table) {
$table->integer('parent_id')
->after('id')
->nullable()
->default(null)
->index()
->comment('ID of parent page');
$table->foreign('parent_id')
->references('id')
->on('contents')
->onDelete('cascade')
->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
* @return void
*/
public function down()
{
Schema::table('contents', function (Blueprint $table) {
$table->dropForeign('contents_parent_id_foreign');
$table->dropColumn('parent_id');
});
}
}