From 1c53ffc4d14457803aa207a52963cfc77d4f0242 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Wed, 7 Dec 2022 14:57:23 +0000 Subject: [PATCH] Updated entity_permissions table for user perms. As start of user permissions work --- ...3821_add_user_id_to_entity_permissions.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 database/migrations/2022_12_07_113821_add_user_id_to_entity_permissions.php 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'); + }); + } +}