From 25e55a620bc94614632f23324dd4f6d337ebaeba Mon Sep 17 00:00:00 2001 From: iglocska Date: Sat, 24 Aug 2024 15:47:53 +0200 Subject: [PATCH] chg: [migration] minor fix for rerunability --- .../20240719000003_AdminPermissionSplit.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 config/Migrations/20240719000003_AdminPermissionSplit.php diff --git a/config/Migrations/20240719000003_AdminPermissionSplit.php b/config/Migrations/20240719000003_AdminPermissionSplit.php new file mode 100644 index 0000000..170a0c5 --- /dev/null +++ b/config/Migrations/20240719000003_AdminPermissionSplit.php @@ -0,0 +1,30 @@ +table('roles')->hasColumn('perm_community_admin'); + if (!$exists) { + $this->table('roles') + ->addColumn('perm_community_admin', 'boolean', [ + 'default' => 0, + 'null' => false, + ]) + ->addIndex('perm_community_admin') + ->update(); + } + $builder = $this->getQueryBuilder(); + $builder + ->update('roles') + ->set('perm_community_admin', true) + ->where(['perm_admin' => true]) + ->execute(); + } +}