FEATURE: add support for submodules
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class MakeModuleHandlerNullable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->string('handler')
|
||||
->nullable(true)
|
||||
->change();
|
||||
|
||||
$table->string('alias')
|
||||
->nullable(true)
|
||||
->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
|
||||
$table->string('alias')
|
||||
->nullable(false)
|
||||
->change();
|
||||
|
||||
// somehow I cannot change it back, sorry...
|
||||
|
||||
// $table->string('handler')
|
||||
// ->nullable(false)
|
||||
// ->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddParentModuleIdToModules extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->integer('parent_id')
|
||||
->nullable(true)
|
||||
->comment('Parent module ID (when module is submodule)')
|
||||
->after('id');
|
||||
$table->boolean('has_submodules')
|
||||
->default(false);
|
||||
|
||||
$table->foreign('parent_id')
|
||||
->references('id')
|
||||
->on('modules')
|
||||
->onDelete('cascade')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->dropForeign('modules_parent_id_foreign');
|
||||
|
||||
$table->dropColumn('has_submodules');
|
||||
$table->dropColumn('parent_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user