Files
coder/coderd/database/migrations/000201_ensure_default_everyone_group.up.sql
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

11 lines
404 B
SQL
Raw Normal View History

-- This ensures a default everyone group exists for default org.
INSERT INTO
groups(name, id, organization_id)
SELECT
-- This is a special keyword that must be exactly this.
'Everyone',
-- Org ID and group ID must match.
(SELECT id FROM organizations WHERE is_default = true LIMIT 1),
(SELECT id FROM organizations WHERE is_default = true LIMIT 1)
-- It might already exist
ON CONFLICT DO NOTHING;