File: /var/www/ipsremont-demo/database/migrations/2020_12_05_011323_roles_constructor.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class RolesConstructor extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('roles', function (Blueprint $table) {
$table->boolean('deletable')->default(1);
$table->boolean('in_constructor')->default(1);
$table->renameColumn('role', 'name');
$table->string('description')->nullable()->change();
$table->index('slug');
$table->index('type');
});
Schema::table('permissions', function (Blueprint $table) {
$table->string('type')->default('both');
$table->index('slug');
$table->index('type');
});
Schema::table('roles_permissions', function (Blueprint $table) {
$table->foreign('role_id')->references('id')->on('roles');
$table->foreign('permission_id')->references('id')->on('permissions');
$table->primary(['role_id','permission_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('roles', function (Blueprint $table) {
$table->dropColumn('deletable');
$table->dropColumn('in_constructor');
$table->renameColumn('name', 'role');
});
}
}