From: Dan Brown Date: Wed, 7 Dec 2022 14:57:23 +0000 (+0000) Subject: Updated entity_permissions table for user perms. X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/1c53ffc4d14457803aa207a52963cfc77d4f0242 Updated entity_permissions table for user perms. As start of user permissions work --- diff --git a/database/migrations/2022_12_07_113821_add_user_id_to_entity_permissions.php b/database/migrations/2022_12_07_113821_add_user_id_to_entity_permissions.php new file mode 100644 index 000000000..9fd9c610e --- /dev/null +++ b/database/migrations/2022_12_07_113821_add_user_id_to_entity_permissions.php @@ -0,0 +1,47 @@ +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'); + }); + } +}