mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: Add user roles, but do not yet enforce them (#1200)
* chore: Rework roles to be expandable by name alone
This commit is contained in:
2
coderd/database/migrations/000008_rbac_roles.down.sql
Normal file
2
coderd/database/migrations/000008_rbac_roles.down.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE ONLY users
|
||||
DROP COLUMN IF EXISTS rbac_roles;
|
18
coderd/database/migrations/000008_rbac_roles.up.sql
Normal file
18
coderd/database/migrations/000008_rbac_roles.up.sql
Normal file
@ -0,0 +1,18 @@
|
||||
ALTER TABLE ONLY users
|
||||
ADD COLUMN IF NOT EXISTS rbac_roles text[] DEFAULT '{}' NOT NULL;
|
||||
|
||||
-- All users are site members. So give them the standard role.
|
||||
-- Also give them membership to the first org we retrieve. We should only have
|
||||
-- 1 organization at this point in the product.
|
||||
UPDATE
|
||||
users
|
||||
SET
|
||||
rbac_roles = ARRAY ['member', 'organization-member:' || (SELECT id FROM organizations LIMIT 1)];
|
||||
|
||||
-- Give the first user created the admin role
|
||||
UPDATE
|
||||
users
|
||||
SET
|
||||
rbac_roles = rbac_roles || ARRAY ['admin']
|
||||
WHERE
|
||||
id = (SELECT id FROM users ORDER BY created_at ASC LIMIT 1)
|
Reference in New Issue
Block a user