admin(roles): add has one on User -> AdminRole
This commit is contained in:
parent
9d005b5fd2
commit
1e61fd161c
4 changed files with 70 additions and 1 deletions
|
@ -14,11 +14,13 @@ class CreateAdminRolesTable extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::create('admin_roles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('id')->unsigned();
|
||||
$table->string('name', 64);
|
||||
$table->string('description', 255)->nullable();
|
||||
$table->integer('sort_id');
|
||||
$table->json('permissions')->nullable();
|
||||
|
||||
$table->unique(['id']);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddAdminRoleIdColumnToUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->integer('admin_role_id')->nullable()->unsigned()->after('language');
|
||||
$table->index('admin_role_id')->nullable();
|
||||
$table->foreign('admin_role_id')->references('id')->on('admin_roles')->onDelete('set null');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropForeign(['admin_role_id']);
|
||||
$table->dropIndex('admin_role_id');
|
||||
$table->dropColumn('admin_role_id');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue