mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Updated entity_permissions table for user perms.
As start of user permissions work
This commit is contained in:
parent
69d702c783
commit
1c53ffc4d1
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddUserIdToEntityPermissions extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('entity_permissions', function (Blueprint $table) {
|
||||||
|
$table->unsignedInteger('role_id')->nullable()->default(null)->change();
|
||||||
|
$table->unsignedInteger('user_id')->nullable()->default(null)->index();
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::table('entity_permissions')
|
||||||
|
->where('role_id', '=', 0)
|
||||||
|
->update(['role_id' => null]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
DB::table('entity_permissions')
|
||||||
|
->whereNull('role_id')
|
||||||
|
->update(['role_id' => 0]);
|
||||||
|
|
||||||
|
DB::table('entity_permissions')
|
||||||
|
->whereNotNull('user_id')
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
Schema::table('entity_permissions', function (Blueprint $table) {
|
||||||
|
$table->unsignedInteger('role_id')->nullable(false)->change();
|
||||||
|
$table->dropColumn('user_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user