- Notifications
You must be signed in to change notification settings - Fork928
chore: Rename 'admin' to 'owner'#3498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
233962c
5ca12ce
52cac69
fb4f80f
81c2ee0
21e48e7
9c122a6
dd9e323
4a4845a
ec56c60
a5598fa
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
UPDATE | ||
users | ||
SET | ||
-- Replace 'template-admin' and 'user-admin' role with 'admin' | ||
rbac_roles = array_append( | ||
array_remove( | ||
array_remove(rbac_roles, 'template-admin'), | ||
'user-admin' | ||
), 'admin') | ||
WHERE | ||
-- Only on existing admins. If they have either role, make them an admin | ||
ARRAY ['template-admin', 'user-admin'] && rbac_roles; | ||
UPDATE | ||
users | ||
SET | ||
-- Replace 'owner' with 'admin' | ||
rbac_roles = array_replace(rbac_roles, 'owner', 'admin') | ||
WHERE | ||
-- Only on the owner | ||
'owner' = ANY(rbac_roles); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
UPDATE | ||
users | ||
SET | ||
-- Replace the role 'admin' with the role 'owner' | ||
rbac_roles = array_replace(rbac_roles, 'admin', 'owner') | ||
WHERE | ||
-- Update the first user with the role 'admin'. This should be the first | ||
-- user ever, but if that user was demoted from an admin, then choose | ||
-- the next best user. | ||
id = (SELECT id FROM users WHERE 'admin' = ANY(rbac_roles) ORDER BY created_at ASC LIMIT 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This could technically cause the query to fail if no rows are found, I think doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Oh interesting. Let me try it out There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. @coadler It does not seem to matter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Hmm, I thought this would've caused an issue when you compared a non-null field to null. Sounds good then! | ||
UPDATE | ||
users | ||
SET | ||
-- Replace 'admin' role with 'template-admin' and 'user-admin' | ||
rbac_roles = array_cat(array_remove(rbac_roles, 'admin'), ARRAY ['template-admin', 'user-admin']) | ||
WHERE | ||
-- Only on existing admins | ||
'admin' = ANY(rbac_roles); | ||
coadler marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. |
Uh oh!
There was an error while loading.Please reload this page.