mirror of
https://github.com/coder/coder.git
synced 2026-06-03 21:18:24 +00:00
35211e2190
* chore: Rework roles to be expandable by name alone
19 lines
579 B
SQL
19 lines
579 B
SQL
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)
|